File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -563,6 +563,25 @@ def xescape(s):
563563 repl .update (html_chars )
564564 return s .translate (repl )
565565
566+ def xescape (s ):
567+ '''combines parts from re.escape & html.escape'''
568+ # https://github.com/python/cpython/blob/3.10/Lib/re.py#L267
569+ # '&' is handled otherwise
570+ re_chars = {i : '\\ ' + chr (i ) for i in b'()[]{}*+-|^$\\ .~# \t \n \r \v \f ' }
571+ # https://github.com/python/cpython/blob/3.10/Lib/html/__init__.py#L12
572+ html_chars = {
573+ '<' : '<' ,
574+ '>' : '>' ,
575+ '"' : '"' ,
576+ "'" : ''' ,
577+ }
578+ # we can't replace '&' because it makes certain zites work incorrectly
579+ # it should however in no way interfere with re.sub in render
580+ repl = {}
581+ repl .update (re_chars )
582+ repl .update (html_chars )
583+ return s .translate (repl )
584+
566585 return self .render (
567586 "src/Ui/template/wrapper.html" ,
568587 server_url = server_url ,
You can’t perform that action at this time.
0 commit comments