Quellcode durchsuchen

properly html-escape included files

Thomas B vor 3 Monaten
Ursprung
Commit
532b472e43
1 geänderte Dateien mit 7 neuen und 1 gelöschten Zeilen
  1. 7
    1
      macros.py

+ 7
- 1
macros.py Datei anzeigen

@@ -18,12 +18,14 @@ from datetime import datetime
18 18
 PY3 = sys.version_info[0] == 3
19 19
 
20 20
 if PY3:
21
+    import html
21 22
     import urllib
22 23
     import urllib.request
23 24
     from urllib.error import HTTPError, URLError
24 25
     def urlparse_foo(link):
25 26
         return urllib.parse.parse_qs(urllib.parse.urlparse(link).query)['v'][0]
26 27
 else:
28
+    import cgi
27 29
     import urllib
28 30
     import urlparse
29 31
     def urlparse_foo(link):
@@ -583,7 +585,11 @@ def printLatestRelease(user, repo):
583 585
 
584 586
 def include_url(url):
585 587
     data = http_request(url)
586
-    print(data, end="")
588
+    if PY3:
589
+        encoded = html.escape(data)
590
+    else:
591
+        encoded = cgi.escape(data)
592
+    print(encoded, end="")
587 593
 
588 594
 # -----------------------------------------------------------------------------
589 595
 # preconvert hooks

Laden…
Abbrechen
Speichern