Skip to content

Commit

Permalink
修复html内容未转义的BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
silentmoooon committed Jun 25, 2019
1 parent 6051d54 commit b66673e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
9 changes: 7 additions & 2 deletions ClipOne/service/ClipService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ public string SaveImage(BitmapSource bs)
JpegBitmapEncoder jpegEncoder = new JpegBitmapEncoder();
jpegEncoder.Frames.Add(BitmapFrame.Create(bs));

using (FileStream fs = new FileStream(path, FileMode.Create)) {
using (FileStream fs = File.OpenWrite(path)) {
jpegEncoder.Save(fs);

}

return path;
Expand Down Expand Up @@ -353,9 +354,13 @@ public void HandleFile(ClipModel clip)
public void HandleHtml(ClipModel clip)
{

string htmlStr = Clipboard.GetData(DataFormats.Html).ToString();
string htmlStr = Clipboard.GetData(DataFormats.Html).ToString().Replace("&","&");

string plainText = Clipboard.GetText();

// Console.WriteLine(htmlStr);

// Console.WriteLine("==");

//只有当html内容中有图片才当作html格式处理,否则做文本处理
if (GetOccurTimes(htmlStr.ToLower(), "<img") > GetOccurTimes(plainText.ToLower(), "<img"))
Expand Down
8 changes: 7 additions & 1 deletion ClipOne/view/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,22 +198,28 @@ private void ClearImage(object images)
//Console.WriteLine("--");
//Console.WriteLine(string.Join(",", image));
//Console.WriteLine("--");

// File.AppendAllText("C:/test/log.txt", "--");
//File.AppendAllText("C:/test/log.txt", string.Join(",", image));
foreach (var img in Directory.GetFiles(cacheDir))
{

if (!image.Contains(img))
{
// File.AppendAllText("C:/test/log.txt", img);
//Console.WriteLine(img);
//Console.WriteLine("==");
DeleteFile(img);
}

}
//File.AppendAllText("C:/test/log.txt", "--\n");

}
private void DeleteFile(object path)
{
// File.AppendAllText("C:/test/log.txt", "==");
// File.AppendAllText("C:/test/log.txt", path.ToString());
// File.AppendAllText("C:/test/log.txt", "==\n");
for (int i = 0; i < 3; i++)
{
Thread.Sleep(i * 500);
Expand Down

0 comments on commit b66673e

Please sign in to comment.