Skip to content

Commit

Permalink
Merge pull request #539 from TechupBusiness/improve-html-entity-encoding
Browse files Browse the repository at this point in the history
[TASK] Improve html entity encoding
  • Loading branch information
kozec authored Oct 30, 2019
2 parents 63a9156 + 0c5e779 commit 5c0e542
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 0 additions & 1 deletion syncthing_gtk/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1406,7 +1406,6 @@ def show_folder(self, id, label, path, folder_type, ignore_perms, rescan_interva
title = display_path
if label not in (None, ""):
title = label
title = title.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;').replace('"', '&quot;').replace("'", '&#39;')
if id in self.folders:
# Reuse existing box
box = self.folders[id]
Expand Down
3 changes: 2 additions & 1 deletion syncthing_gtk/infobox.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from __future__ import unicode_literals
from gi.repository import Gtk, Gdk, GLib, GObject, Pango, Rsvg
from syncthing_gtk.ribar import RevealerClass
from syncthing_gtk.tools import _ # gettext function
from syncthing_gtk.tools import _, escape_html_entities # _ is gettext function
import os, logging, math
log = logging.getLogger("InfoBox")

Expand Down Expand Up @@ -313,6 +313,7 @@ def on_leave_notify(self, eb, event, *data):

### Methods
def set_title(self, t):
t = escape_html_entities(t)
self.str_title = t
inverted = self.header_inverted and self.dark_color is None
col = "black" if inverted else "white"
Expand Down
3 changes: 3 additions & 0 deletions syncthing_gtk/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,3 +558,6 @@ def generate_folder_id():
("".join(random.choice(string.ascii_lowercase + string.digits) for _ in range(5)))
for _ in range(2)
))

def escape_html_entities(string):
return string.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;').replace('"', '&quot;').replace("'", '&#39;')

0 comments on commit 5c0e542

Please sign in to comment.