Use html encoding for text in "Networking" mode

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@202 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2010-12-27 19:47:54 +00:00
parent e07f7f4427
commit 101221d700

View File

@ -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, "<br />")
Text = Utilities.HtmlEncode(p.Text.Replace(Environment.NewLine, "<br />"))
});
}
@ -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, "<br />")
Text = Utilities.HtmlEncode(p.Text.Replace(Environment.NewLine, "<br />"))
});
}
}
@ -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("<br />", Environment.NewLine), sequence.StartMilliseconds, sequence.EndMilliseconds));
Subtitle.Paragraphs.Add(new Paragraph(HttpUtility.HtmlDecode(sequence.Text).Replace("<br />", 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("<br />", Environment.NewLine), sequence.StartMilliseconds, sequence.EndMilliseconds));
OriginalSubtitle.Paragraphs.Add(new Paragraph(HttpUtility.HtmlDecode(sequence.Text).Replace("<br />", 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("<br />", Environment.NewLine), sequence.StartMilliseconds, sequence.EndMilliseconds);
Paragraph p = new Paragraph(HttpUtility.HtmlDecode(sequence.Text).Replace("<br />", 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, "<br />"), CurrentUser);
_seWs.SendMessage(SessionId, Utilities.HtmlEncode(message.Replace(Environment.NewLine, "<br />")), 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, "<br />")
Text = Utilities.HtmlEncode(paragraph.Text.Replace(Environment.NewLine, "<br />"))
}, CurrentUser);
AddToWsUserLog(CurrentUser, index, "UPD", true);
}