From 101221d700920f7eb446cf90ec7050f761e47a5b Mon Sep 17 00:00:00 2001 From: niksedk Date: Mon, 27 Dec 2010 19:47:54 +0000 Subject: [PATCH] Use html encoding for text in "Networking" mode git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@202 99eadd0c-20b8-1223-b5c4-2a2b2df33de2 --- src/Logic/Networking/NikseWebServiceSession.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Logic/Networking/NikseWebServiceSession.cs b/src/Logic/Networking/NikseWebServiceSession.cs index 4f8bde4f1..623ad9e47 100644 --- a/src/Logic/Networking/NikseWebServiceSession.cs +++ b/src/Logic/Networking/NikseWebServiceSession.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Text; +using System.Web; namespace Nikse.SubtitleEdit.Logic.Networking { @@ -59,7 +60,7 @@ namespace Nikse.SubtitleEdit.Logic.Networking { StartMilliseconds = (int)p.StartTime.TotalMilliseconds, EndMilliseconds = (int)p.EndTime.TotalMilliseconds, - Text = p.Text.Replace(Environment.NewLine, "
") + Text = Utilities.HtmlEncode(p.Text.Replace(Environment.NewLine, "
")) }); } @@ -72,7 +73,7 @@ namespace Nikse.SubtitleEdit.Logic.Networking { StartMilliseconds = (int)p.StartTime.TotalMilliseconds, EndMilliseconds = (int)p.EndTime.TotalMilliseconds, - Text = p.Text.Replace(Environment.NewLine, "
") + Text = Utilities.HtmlEncode(p.Text.Replace(Environment.NewLine, "
")) }); } } @@ -103,7 +104,7 @@ namespace Nikse.SubtitleEdit.Logic.Networking DateTime updateTime; Subtitle = new Subtitle(); foreach (var sequence in _seWs.GetSubtitle(sessionKey, out tempFileName, out updateTime)) - Subtitle.Paragraphs.Add(new Paragraph(sequence.Text.Replace("
", Environment.NewLine), sequence.StartMilliseconds, sequence.EndMilliseconds)); + Subtitle.Paragraphs.Add(new Paragraph(HttpUtility.HtmlDecode(sequence.Text).Replace("
", Environment.NewLine), sequence.StartMilliseconds, sequence.EndMilliseconds)); FileName = tempFileName; OriginalSubtitle = new Subtitle(); @@ -111,7 +112,7 @@ namespace Nikse.SubtitleEdit.Logic.Networking if (sequences != null) { foreach (var sequence in sequences) - OriginalSubtitle.Paragraphs.Add(new Paragraph(sequence.Text.Replace("
", Environment.NewLine), sequence.StartMilliseconds, sequence.EndMilliseconds)); + OriginalSubtitle.Paragraphs.Add(new Paragraph(HttpUtility.HtmlDecode(sequence.Text).Replace("
", Environment.NewLine), sequence.StartMilliseconds, sequence.EndMilliseconds)); } SessionId = sessionKey; @@ -155,7 +156,7 @@ namespace Nikse.SubtitleEdit.Logic.Networking var sequences = _seWs.GetSubtitle(SessionId, out FileName, out _seWsLastUpdate); foreach (var sequence in sequences) { - Paragraph p = new Paragraph(sequence.Text.Replace("
", Environment.NewLine), sequence.StartMilliseconds, sequence.EndMilliseconds); + Paragraph p = new Paragraph(HttpUtility.HtmlDecode(sequence.Text).Replace("
", Environment.NewLine), sequence.StartMilliseconds, sequence.EndMilliseconds); Subtitle.Paragraphs.Add(p); } Subtitle.Renumber(1); @@ -166,7 +167,7 @@ namespace Nikse.SubtitleEdit.Logic.Networking public void Log(string text) { string timestamp = DateTime.Now.ToLongTimeString(); - _log.AppendLine(timestamp + ": " + text.TrimEnd() .Replace(Environment.NewLine, Configuration.Settings.General.ListViewLineSeparatorString)); + _log.AppendLine(timestamp + ": " + text.TrimEnd().Replace(Environment.NewLine, Configuration.Settings.General.ListViewLineSeparatorString)); } public string GetLog() @@ -176,7 +177,7 @@ namespace Nikse.SubtitleEdit.Logic.Networking public void SendChatMessage(string message) { - _seWs.SendMessage(SessionId, message.Replace(Environment.NewLine, "
"), CurrentUser); + _seWs.SendMessage(SessionId, Utilities.HtmlEncode(message.Replace(Environment.NewLine, "
")), CurrentUser); } internal void UpdateLine(int index, Paragraph paragraph) @@ -185,7 +186,7 @@ namespace Nikse.SubtitleEdit.Logic.Networking { StartMilliseconds = (int)paragraph.StartTime.TotalMilliseconds, EndMilliseconds = (int)paragraph.EndTime.TotalMilliseconds, - Text = paragraph.Text.Replace(Environment.NewLine, "
") + Text = Utilities.HtmlEncode(paragraph.Text.Replace(Environment.NewLine, "
")) }, CurrentUser); AddToWsUserLog(CurrentUser, index, "UPD", true); }