# HG changeset patch # User Siddharth Agarwal # Date 1350319414 25200 # Node ID 823a7d79ef82010f614a2914f5f24723b2f815e1 # Parent dcfa526b180bdc648c19df40fb6df9ddcde241d8 hgweb: make the escape filter remove null characters (issue2567) diff -r dcfa526b180b -r 823a7d79ef82 mercurial/templatefilters.py --- a/mercurial/templatefilters.py Tue Oct 16 16:56:14 2012 +0200 +++ b/mercurial/templatefilters.py Mon Oct 15 09:43:34 2012 -0700 @@ -92,9 +92,9 @@ def escape(text): """:escape: Any text. Replaces the special XML/XHTML characters "&", "<" - and ">" with XML entities. + and ">" with XML entities, and filters out NUL characters. """ - return cgi.escape(text, True) + return cgi.escape(text.replace('\0', ''), True) para_re = None space_re = None diff -r dcfa526b180b -r 823a7d79ef82 tests/test-hgweb-commands.t --- a/tests/test-hgweb-commands.t Tue Oct 16 16:56:14 2012 +0200 +++ b/tests/test-hgweb-commands.t Mon Oct 15 09:43:34 2012 -0700 @@ -27,7 +27,10 @@ $ hg branch unstable marked working directory as branch unstable (branches are permanent and global, did you want a bookmark?) - $ hg ci -Ambranch + >>> open('msg', 'wb').write('branch commit with null character: \0\n') + $ hg ci -l msg + $ rm msg + $ echo [graph] >> .hg/hgrc $ echo default.width = 3 >> .hg/hgrc $ echo stable.width = 3 >> .hg/hgrc @@ -35,7 +38,7 @@ $ hg serve --config server.uncompressed=False -n test -p $HGPORT -d --pid-file=hg.pid -E errors.log $ cat hg.pid >> $DAEMON_PIDS $ hg log -G --template '{rev}:{node|short} {desc}\n' - @ 3:ba87b23d29ca branch + @ 3:cad8025a2e87 branch commit with null character: \x00 (esc) | o 2:1d22e65f027e branch | @@ -59,9 +62,9 @@ 1970-01-01T00:00:00+00:00 - branch - http://*:$HGPORT/#changeset-ba87b23d29ca67a305625d81a20ac279c1e3f444 (glob) - (glob) + branch commit with null character: + http://*:$HGPORT/#changeset-cad8025a2e87f88c06259790adfa15acb4080123 (glob) + (glob) test test @@ -70,7 +73,7 @@ 1970-01-01T00:00:00+00:00
-
branch
+
branch commit with null character: 
@@ -137,9 +140,9 @@ 1970-01-01T00:00:00+00:00 - branch - http://*:$HGPORT/#changeset-ba87b23d29ca67a305625d81a20ac279c1e3f444 (glob) - (glob) + branch commit with null character: + http://*:$HGPORT/#changeset-cad8025a2e87f88c06259790adfa15acb4080123 (glob) + (glob) test test @@ -148,7 +151,7 @@ 1970-01-01T00:00:00+00:00
-
branch
+
branch commit with null character: 
@@ -257,14 +260,14 @@