# HG changeset patch # User Peter van Dijk # Date 1138490332 -3600 # Node ID f2ebd5251e88cd4f8215e607c8446a9f903a90a9 # Parent beb7da710c8a8cb560b64cc7c5150339f824cfae changed template escape filter, added urlescape filter; audited all templates for insertion bugs; added note to manifest.py about newlines in filenames diff -r beb7da710c8a -r f2ebd5251e88 mercurial/hgweb.py --- a/mercurial/hgweb.py Sun Jan 29 11:17:54 2006 +1300 +++ b/mercurial/hgweb.py Sun Jan 29 00:18:52 2006 +0100 @@ -6,7 +6,7 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -import os, cgi, sys +import os, cgi, sys, urllib from demandload import demandload demandload(globals(), "mdiff time re socket zlib errno ui hg ConfigParser") demandload(globals(), "zipfile tempfile StringIO tarfile BaseHTTPServer util") @@ -163,7 +163,8 @@ return common_filters = { - "escape": cgi.escape, + "escape": lambda x: cgi.escape(x, True), + "urlescape": urllib.quote, "strip": lambda x: x.strip(), "age": age, "date": lambda x: util.datestr(x), diff -r beb7da710c8a -r f2ebd5251e88 mercurial/manifest.py --- a/mercurial/manifest.py Sun Jan 29 11:17:54 2006 +1300 +++ b/mercurial/manifest.py Sun Jan 29 00:18:52 2006 +0100 @@ -108,6 +108,8 @@ files = map.keys() files.sort() + % if this is changed to support newlines in filenames, + % be sure to check the templates/ dir again (especially *-raw.tmpl) text = ["%s\000%s%s\n" % (f, hex(map[f]), flags[f] and "x" or '') for f in files] diff -r beb7da710c8a -r f2ebd5251e88 templates/changelog-gitweb.tmpl --- a/templates/changelog-gitweb.tmpl Sun Jan 29 11:17:54 2006 +1300 +++ b/templates/changelog-gitweb.tmpl Sun Jan 29 00:18:52 2006 +0100 @@ -11,7 +11,7 @@
-#desc|addbreaks# +#desc|escape|addbreaks#

diff -r beb7da710c8a -r f2ebd5251e88 templates/changeset-gitweb.tmpl --- a/templates/changeset-gitweb.tmpl Sun Jan 29 11:17:54 2006 +1300 +++ b/templates/changeset-gitweb.tmpl Sun Jan 29 00:18:52 2006 +0100 @@ -28,7 +28,7 @@
-#desc|addbreaks# +#desc|escape|addbreaks#
diff -r beb7da710c8a -r f2ebd5251e88 templates/fileannotate-gitweb.tmpl --- a/templates/fileannotate-gitweb.tmpl Sun Jan 29 11:17:54 2006 +1300 +++ b/templates/fileannotate-gitweb.tmpl Sun Jan 29 00:18:52 2006 +0100 @@ -10,10 +10,10 @@
-
#file#
+
#file|escape#
diff -r beb7da710c8a -r f2ebd5251e88 templates/fileannotate.tmpl --- a/templates/fileannotate.tmpl Sun Jan 29 11:17:54 2006 +1300 +++ b/templates/fileannotate.tmpl Sun Jan 29 00:18:52 2006 +0100 @@ -1,5 +1,5 @@ #header# -#repo|escape#: #file# annotate +#repo|escape#: #file|escape# annotate @@ -7,12 +7,12 @@ changelogtagschangeset -manifest -file -revisions +manifest +file +revisions -

Annotate #file#

+

Annotate #file|escape#

diff -r beb7da710c8a -r f2ebd5251e88 templates/filediff.tmpl --- a/templates/filediff.tmpl Sun Jan 29 11:17:54 2006 +1300 +++ b/templates/filediff.tmpl Sun Jan 29 00:18:52 2006 +0100 @@ -1,5 +1,5 @@ #header# -#repo|escape#: #file# diff +#repo|escape#: #file|escape# diff @@ -7,13 +7,13 @@ changelogtagschangeset -file -revisions -annotate -raw +file +revisions +annotate +raw -

#file#

+

#file|escape#

diff -r beb7da710c8a -r f2ebd5251e88 templates/filelog-gitweb.tmpl --- a/templates/filelog-gitweb.tmpl Sun Jan 29 11:17:54 2006 +1300 +++ b/templates/filelog-gitweb.tmpl Sun Jan 29 00:18:52 2006 +0100 @@ -10,7 +10,7 @@
diff -r beb7da710c8a -r f2ebd5251e88 templates/filelog-rss.tmpl --- a/templates/filelog-rss.tmpl Sun Jan 29 11:17:54 2006 +1300 +++ b/templates/filelog-rss.tmpl Sun Jan 29 00:18:52 2006 +0100 @@ -1,6 +1,6 @@ #header# - #repo|escape#: #file# history - #file# revision history + #repo|escape#: #file|escape# history + #file|escape# revision history #entries%filelogentry# - \ No newline at end of file + diff -r beb7da710c8a -r f2ebd5251e88 templates/filelog.tmpl --- a/templates/filelog.tmpl Sun Jan 29 11:17:54 2006 +1300 +++ b/templates/filelog.tmpl Sun Jan 29 00:18:52 2006 +0100 @@ -1,7 +1,7 @@ #header# -#repo|escape#: #file# history +#repo|escape#: #file|escape# history + href="?fl=0;file=#file|urlescape#;style=rss" title="RSS feed for #repo|escape#:#file#"> @@ -9,12 +9,12 @@ -

#file# revision history

+

#file|escape# revision history

#entries%filelogentry# diff -r beb7da710c8a -r f2ebd5251e88 templates/filelogentry-rss.tmpl --- a/templates/filelogentry-rss.tmpl Sun Jan 29 11:17:54 2006 +1300 +++ b/templates/filelogentry-rss.tmpl Sun Jan 29 00:18:52 2006 +0100 @@ -1,6 +1,6 @@ #desc|strip|firstline|strip|escape# - #url#?f=#filenode|short#;file=#file# + #url#?f=#filenode|short#;file=#file|urlescape# #author|obfuscate# #date|rfc822date#> diff -r beb7da710c8a -r f2ebd5251e88 templates/filelogentry.tmpl --- a/templates/filelogentry.tmpl Sun Jan 29 11:17:54 2006 +1300 +++ b/templates/filelogentry.tmpl Sun Jan 29 00:18:52 2006 +0100 @@ -4,9 +4,9 @@ - diff -r beb7da710c8a -r f2ebd5251e88 templates/filerevision-gitweb.tmpl --- a/templates/filerevision-gitweb.tmpl Sun Jan 29 11:17:54 2006 +1300 +++ b/templates/filerevision-gitweb.tmpl Sun Jan 29 00:18:52 2006 +0100 @@ -10,10 +10,10 @@ -
#file#
+
#file|escape#
#desc|strip|firstline|escape#
revision #filerev#: #filenode|short# -(diff) -(annotate) + #filenode|short# +(diff) +(annotate)
author: 
diff -r beb7da710c8a -r f2ebd5251e88 templates/filerevision.tmpl --- a/templates/filerevision.tmpl Sun Jan 29 11:17:54 2006 +1300 +++ b/templates/filerevision.tmpl Sun Jan 29 00:18:52 2006 +0100 @@ -1,5 +1,5 @@ #header# -#repo|escape#:#file# +#repo|escape#:#file|escape# @@ -7,13 +7,13 @@ changelogtagschangeset -manifest -revisions -annotate -raw +manifest +revisions +annotate +raw -

#file#

+

#file|escape#

diff -r beb7da710c8a -r f2ebd5251e88 templates/manifest-gitweb.tmpl --- a/templates/manifest-gitweb.tmpl Sun Jan 29 11:17:54 2006 +1300 +++ b/templates/manifest-gitweb.tmpl Sun Jan 29 00:18:52 2006 +0100 @@ -18,7 +18,7 @@
- + #dentries%manifestdirentry# diff -r beb7da710c8a -r f2ebd5251e88 templates/manifest.tmpl --- a/templates/manifest.tmpl Sun Jan 29 11:17:54 2006 +1300 +++ b/templates/manifest.tmpl Sun Jan 29 00:18:52 2006 +0100 @@ -10,12 +10,12 @@ #archives%archiveentry# -

manifest for changeset #node|short#: #path#

+

manifest for changeset #node|short#: #path|escape#

drwxr-xr-x[up][up]
drwxr-xr-x  - [up] + [up] #dentries%manifestdirentry# #fentries%manifestfileentry#
diff -r beb7da710c8a -r f2ebd5251e88 templates/map --- a/templates/map Sun Jan 29 11:17:54 2006 +1300 +++ b/templates/map Sun Jan 29 00:18:52 2006 +0100 @@ -3,16 +3,16 @@ footer = footer.tmpl search = search.tmpl changelog = changelog.tmpl -naventry = "#label# " -filedifflink = "#file# " -filenodelink = "#file# " +naventry = "#label|escape# " +filedifflink = "#file|escape# " +filenodelink = "#file|escape# " fileellipses = "..." changelogentry = changelogentry.tmpl searchentry = changelogentry.tmpl changeset = changeset.tmpl manifest = manifest.tmpl -manifestdirentry = "drwxr-xr-x #basename#/" -manifestfileentry = "#permissions|permissions# #basename#" +manifestdirentry = "drwxr-xr-x #basename|escape#/" +manifestfileentry = "#permissions|permissions# #basename|escape#" filerevision = filerevision.tmpl fileannotate = fileannotate.tmpl filediff = filediff.tmpl @@ -26,23 +26,23 @@ diffline = "#line|escape#" changelogparent = "parent #rev#:#node|short#" changesetparent = "parent #rev#:#node|short#" -filerevparent = "parent:#node|short#" -fileannotateparent = "parent:#node|short#" +filerevparent = "parent:#node|short#" +fileannotateparent = "parent:#node|short#" changesetchild = "child #rev#:#node|short#" changelogchild = "child #rev#:#node|short#" -filerevchild = "child:#node|short#" -fileannotatechild = "child:#node|short#" +filerevchild = "child:#node|short#" +fileannotatechild = "child:#node|short#" tags = tags.tmpl -tagentry = "
  • #node# #tag#
  • " +tagentry = "
  • #node# #tag|escape#
  • " diffblock = "
    #lines#
    " -changelogtag = "tag:#tag#" -changesettag = "tag:#tag#" +changelogtag = "tag:#tag|escape#" +changesettag = "tag:#tag|escape#" filediffparent = "parent #rev#:#node|short#" -filelogparent = "parent #rev#: #node|short#" +filelogparent = "parent #rev#: #node|short#" filediffchild = "child #rev#:#node|short#" -filelogchild = "child #rev#: #node|short#" -indexentry = "#name##shortdesc##contact|obfuscate##lastupdate|age# agoRSS" +filelogchild = "child #rev#: #node|short#" +indexentry = "#name|escape##shortdesc|escape##contact|obfuscate##lastupdate|age# agoRSS" index = index.tmpl -archiveentry = "#type# " +archiveentry = "#type|escape# " notfound = notfound.tmpl error = error.tmpl diff -r beb7da710c8a -r f2ebd5251e88 templates/map-gitweb --- a/templates/map-gitweb Sun Jan 29 11:17:54 2006 +1300 +++ b/templates/map-gitweb Sun Jan 29 00:18:52 2006 +0100 @@ -5,17 +5,17 @@ changelog = changelog-gitweb.tmpl summary = summary-gitweb.tmpl error = error-gitweb.tmpl -naventry = "#label# " -navshortentry = "#label# " -filedifflink = "#file# " -filenodelink = "#file#file | revisions" +naventry = "#label|escape# " +navshortentry = "#label|escape# " +filedifflink = "#file|escape# " +filenodelink = "#file|escape#file | revisions" fileellipses = "..." changelogentry = changelogentry-gitweb.tmpl searchentry = changelogentry-gitweb.tmpl changeset = changeset-gitweb.tmpl manifest = manifest-gitweb.tmpl -manifestdirentry = "drwxr-xr-x#basename#/manifest" -manifestfileentry = "#permissions|permissions##basename#file | revisions | annotate" +manifestdirentry = "drwxr-xr-x#basename|escape#/manifest" +manifestfileentry = "#permissions|permissions##basename|escape#file | revisions | annotate" filerevision = filerevision-gitweb.tmpl fileannotate = fileannotate-gitweb.tmpl filelog = filelog-gitweb.tmpl @@ -28,22 +28,22 @@ diffline = "
    #line|escape#
    " changelogparent = "parent #rev#:#node|short#" changesetparent = "parent#node|short#" -filerevparent = "parent:#node|short#" -fileannotateparent = "parent:#node|short#" +filerevparent = "parent:#node|short#" +fileannotateparent = "parent:#node|short#" changelogchild = "child #rev#:#node|short#" changesetchild = "child#node|short#" -filerevchild = "child:#node|short#" -fileannotatechild = "child:#node|short#" +filerevchild = "child:#node|short#" +fileannotatechild = "child:#node|short#" tags = tags-gitweb.tmpl -tagentry = "#date|age# ago#tag#changeset | changelog | manifest" +tagentry = "#date|age# ago#tag|escape#changeset | changelog | manifest" diffblock = "#lines#" -changelogtag = "tag:#tag#" -changesettag = "tag#tag#" +changelogtag = "tag:#tag|escape#" +changesettag = "tag#tag|escape#" filediffparent = "parent #rev#:#node|short#" -filelogparent = "parent #rev#: #node|short#" +filelogparent = "parent #rev#: #node|short#" filediffchild = "child #rev#:#node|short#" -filelogchild = "child #rev#: #node|short#" +filelogchild = "child #rev#: #node|short#" shortlog = shortlog-gitweb.tmpl shortlogentry = "#date|age# ago#desc|firstline|escape#changeset | manifest" -filelogentry = "#date|age# ago#desc|firstline|escape# annotate" -archiveentry = " | #type# " +filelogentry = "#date|age# ago#desc|firstline|escape# annotate" +archiveentry = " | #type|escape# " diff -r beb7da710c8a -r f2ebd5251e88 templates/map-raw --- a/templates/map-raw Sun Jan 29 11:17:54 2006 +1300 +++ b/templates/map-raw Sun Jan 29 00:18:52 2006 +0100 @@ -1,15 +1,15 @@ header = header-raw.tmpl footer = "" changeset = changeset-raw.tmpl -annotateline = "#author#@#rev#
    #line#
    " -difflineplus = "#line#" -difflineminus = "#line#" -difflineat = "#line#" -diffline = "#line#" +annotateline = "#author#@#rev#
    #line|escape#
    " +difflineplus = "#line|escape#" +difflineminus = "#line|escape#" +difflineat = "#line|escape#" +diffline = "#line|escape#" changesetparent = "# parent: #node#" changesetchild = "# child: #node#" -filenodelink = "#file#" +filenodelink = "#file|urlescape#" filerevision = filerevision-raw.tmpl -fileline = "#line#" +fileline = "#line|escape#" diffblock = "#lines#" filediff = filediff-raw.tmpl diff -r beb7da710c8a -r f2ebd5251e88 templates/summary-gitweb.tmpl --- a/templates/summary-gitweb.tmpl Sun Jan 29 11:17:54 2006 +1300 +++ b/templates/summary-gitweb.tmpl Sun Jan 29 00:18:52 2006 +0100 @@ -14,14 +14,14 @@
     
    - - + +
    description#desc#
    owner#owner#
    description#desc|escape#
    owner#owner|escape#
    changes
    -#shortlog# +#shortlog|escape#
    ...