Issue698

Title interhg produces invalid HTML in shortlog
Priority bug Status chatting
Superseder Nosy List Edward, ThomasAH, certik, kirr, ohachige, tonfa
Assigned To Topics hgweb, patch

Created on 2007-08-20.17:12:41 by ThomasAH, last changed 2008-06-29.11:36:12 by kirr.

Messages
msg4709 (view) Author: ThomasAH Date: 2007-12-26.09:27:37
issue896 is a duplicate of this
msg4158 (view) Author: Edward Date: 2007-10-20.01:44:42
For a workaround for now, you can just make a span with onclick, etc.

bugzilla = s|((?:bug|b=|(?=#?\d{4,}))(?:\s*#?)(\d+))|<span
style="text-decoration: underline;" onclick="event.preventDefault();
document.location = 'https://bugzilla.mozilla.org/show_bug.cgi?id=\2';"
onmouseover="window.status = 'https://bugzilla.mozilla.org/show_bug.cgi?id=\2';"
onmouseout="window.status = '';" title="View bug \2">\1</span>|i
msg3916 (view) Author: ohachige Date: 2007-08-25.16:16:03
How about something like this?

diff -r 6ce2da9aa1c7 hgext/interhg.py
--- a/hgext/interhg.py  Sun Aug 26 01:04:15 2007 +0900
+++ b/hgext/interhg.py  Sun Aug 26 01:12:07 2007 +0900
@@ -27,19 +27,19 @@ from mercurial.hgweb import hgweb_mod
 from mercurial.hgweb import hgweb_mod
 from mercurial import templater

-orig_escape = templater.common_filters["escape"]
+orig_decorate = templater.common_filters["decorate"]

 interhg_table = []

-def interhg_escape(x):
-    escstr = orig_escape(x)
+def interhg_decorate(x):
+    escstr = orig_decorate(x)
     for pat in interhg_table:
         regexp = pat[0]
         format = pat[1]
         escstr = regexp.sub(format, escstr)
     return escstr

-templater.common_filters["escape"] = interhg_escape
+templater.common_filters["decorate"] = interhg_decorate

 orig_refresh = hgweb_mod.hgweb.refresh

diff -r 6ce2da9aa1c7 mercurial/templater.py
--- a/mercurial/templater.py    Sun Aug 26 01:04:15 2007 +0900
+++ b/mercurial/templater.py    Sun Aug 26 01:12:07 2007 +0900
@@ -260,6 +260,7 @@ common_filters = {
     "domain": domain,
     "email": email,
     "escape": lambda x: cgi.escape(x, True),
+    "decorate": lambda x: x,
     "fill68": lambda x: fill(x, width=68),
     "fill76": lambda x: fill(x, width=76),
     "firstline": firstline,
diff -r 6ce2da9aa1c7 templates/changelogentry.tmpl
--- a/templates/changelogentry.tmpl     Sun Aug 26 01:04:15 2007 +0900
+++ b/templates/changelogentry.tmpl     Sun Aug 26 01:12:07 2007 +0900
@@ -1,7 +1,7 @@
 <table class="logEntry parity#parity#">
  <tr>
   <th class="age">#date|age# ago:</th>
-  <th class="firstline">#desc|strip|firstline|escape#</th>
+  <th class="firstline">#desc|strip|firstline|escape|decorate#</th>
  </tr>
  <tr>
   <th class="revision">changeset #rev#:</th>
diff -r 6ce2da9aa1c7 templates/changeset.tmpl
--- a/templates/changeset.tmpl  Sun Aug 26 01:04:15 2007 +0900
+++ b/templates/changeset.tmpl  Sun Aug 26 01:12:07 2007 +0900
@@ -34,7 +34,7 @@
  <td class="files">#files#</td></tr>
 <tr>
  <th class="description">description:</th>
- <td class="description">#desc|strip|escape|addbreaks#</td>
+ <td class="description">#desc|strip|escape|decorate|addbreaks#</td>
 </tr>
 </table>
msg3863 (view) Author: ThomasAH Date: 2007-08-20.17:12:38
I have enabled interhg on the crew and crew-stable repositories.

In the shortlog the summaries are links to the revision pages, therefore
replacing escaped text with something that contains an HTML link produces broken
HTML, see e.g. on http://hg.intevation.org/mercurial/crew/shortlog/ee702e7f181f
which contains nested <a></a> tags:
<a href="/mercurial/crew/rev/64888ff907f4">Fix <a
href="http://www.selenic.com/mercurial/bts/issue685">issue 685</a>: trackback in
grep -r after rename</a>

My interhg config entry:
[interhg]
pat1 = s/(?<=\W)(issue\s*)(\d+)/<a
href="http:\/\/www.selenic.com\/mercurial\/bts\/issue\2">\1\2<\/a>/
History
Date User Action Args
2008-06-29 11:36:12kirrsetnosy: + kirr
2008-02-11 13:03:39djcsettopic: + patch
nosy: ThomasAH, tonfa, ohachige, Edward, certik
2007-12-26 09:27:54ThomasAHlinkissue896 superseder
2007-12-26 09:27:38ThomasAHsetnosy: + certik
messages: + msg4709
2007-10-20 01:44:42Edwardsetnosy: + Edward
messages: + msg4158
2007-08-25 16:16:04ohachigesetstatus: unread -> chatting
nosy: ThomasAH, tonfa, ohachige
messages: + msg3916
2007-08-20 17:12:42ThomasAHcreate