Mercurial > hg
changeset 17421:3eb85477c0d9 stable
hgweb: avoid bad $$ processing in graph (issue3601)
JavaScript .replace always magically processed $$ $& $' $` in replacement
strings and thus displayed subject lines incorrectly in the graph view.
Instead of regexps and .replace we now just create the strings the right way in
the first place.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Wed, 29 Aug 2012 02:09:43 +0200 |
parents | d79df9fd5374 |
children | 93bc65e970c0 1e104d8198d7 b6fab957b27d |
files | mercurial/templates/gitweb/graph.tmpl mercurial/templates/monoblue/graph.tmpl mercurial/templates/paper/graph.tmpl mercurial/templates/spartan/graph.tmpl tests/test-hgweb-commands.t tests/test-hgweb-empty.t |
diffstat | 6 files changed, 26 insertions(+), 74 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/templates/gitweb/graph.tmpl Wed Aug 29 13:16:56 2012 -0500 +++ b/mercurial/templates/gitweb/graph.tmpl Wed Aug 29 02:09:43 2012 +0200 @@ -51,11 +51,6 @@ var graph = new Graph(); graph.scale({bg_height}); -var revlink = '<li style="_STYLE"><span class="desc">'; -revlink += '<a class="list" href="{url}rev/_NODEID{sessionvars%urlparameter}" title="_NODEID"><b>_DESC</b></a>'; -revlink += '</span> _TAGS'; -revlink += '<span class="info">_DATE, by _USER</span></li>'; - graph.vertex = function(x, y, color, parity, cur) \{ this.ctx.beginPath(); @@ -66,13 +61,6 @@ var bg = '<li class="bg parity' + parity + '"></li>'; var left = (this.columns + 1) * this.bg_height; var nstyle = 'padding-left: ' + left + 'px;'; - var item = revlink.replace(/_STYLE/, nstyle); - item = item.replace(/_PARITY/, 'parity' + parity); - item = item.replace(/_NODEID/, cur[0]); - item = item.replace(/_NODEID/, cur[0]); - item = item.replace(/_DESC/, cur[3]); - item = item.replace(/_USER/, cur[4]); - item = item.replace(/_DATE/, cur[5]); var tagspan = ''; if (cur[7].length || cur[8].length || (cur[6][0] != 'default' || cur[6][1])) \{ @@ -99,7 +87,11 @@ tagspan += '</span>'; } - item = item.replace(/_TAGS/, tagspan); + var item = '<li style="' + nstyle + '"><span class="desc">'; + item += '<a class="list" href="{url}rev/' + cur[0] + '{sessionvars%urlparameter}" title="' + cur[0] + '"><b>' + cur[3] + '</b></a>'; + item += '</span> ' + tagspan + ''; + item += '<span class="info">' + cur[5] + ', by ' + cur[4] + '</span></li>'; + return [bg, item]; }
--- a/mercurial/templates/monoblue/graph.tmpl Wed Aug 29 13:16:56 2012 -0500 +++ b/mercurial/templates/monoblue/graph.tmpl Wed Aug 29 02:09:43 2012 +0200 @@ -49,10 +49,6 @@ var graph = new Graph(); graph.scale({bg_height}); - var revlink = '<li style="_STYLE"><span class="desc">'; - revlink += '<a href="{url}rev/_NODEID{sessionvars%urlparameter}" title="_NODEID">_DESC</a>'; - revlink += '</span>_TAGS<span class="info">_DATE, by _USER</span></li>'; - graph.vertex = function(x, y, color, parity, cur) \{ this.ctx.beginPath(); @@ -63,13 +59,6 @@ var bg = '<li class="bg parity' + parity + '"></li>'; var left = (this.columns + 1) * this.bg_height; var nstyle = 'padding-left: ' + left + 'px;'; - var item = revlink.replace(/_STYLE/, nstyle); - item = item.replace(/_PARITY/, 'parity' + parity); - item = item.replace(/_NODEID/, cur[0]); - item = item.replace(/_NODEID/, cur[0]); - item = item.replace(/_DESC/, cur[3]); - item = item.replace(/_USER/, cur[4]); - item = item.replace(/_DATE/, cur[5]); var tagspan = ''; if (cur[7].length || cur[8].length || (cur[6][0] != 'default' || cur[6][1])) \{ @@ -96,7 +85,10 @@ tagspan += '</span>'; } - item = item.replace(/_TAGS/, tagspan); + var item = '<li style="' + nstyle + '"><span class="desc">'; + item += '<a href="{url}rev/' + cur[0] + '{sessionvars%urlparameter}" title="' + cur[0] + '">' + cur[3] + '</a>'; + item += '</span>' + tagspan + '<span class="info">' + cur[5] + ', by ' + cur[4] + '</span></li>'; + return [bg, item]; }
--- a/mercurial/templates/paper/graph.tmpl Wed Aug 29 13:16:56 2012 -0500 +++ b/mercurial/templates/paper/graph.tmpl Wed Aug 29 02:09:43 2012 +0200 @@ -62,10 +62,6 @@ var graph = new Graph(); graph.scale({bg_height}); -var revlink = '<li style="_STYLE"><span class="desc">'; -revlink += '<a href="{url}rev/_NODEID{sessionvars%urlparameter}" title="_NODEID">_DESC</a>'; -revlink += '</span>_TAGS<span class="info">_DATE, by _USER</span></li>'; - graph.vertex = function(x, y, color, parity, cur) \{ this.ctx.beginPath(); @@ -76,13 +72,6 @@ var bg = '<li class="bg parity' + parity + '"></li>'; var left = (this.columns + 1) * this.bg_height; var nstyle = 'padding-left: ' + left + 'px;'; - var item = revlink.replace(/_STYLE/, nstyle); - item = item.replace(/_PARITY/, 'parity' + parity); - item = item.replace(/_NODEID/, cur[0]); - item = item.replace(/_NODEID/, cur[0]); - item = item.replace(/_DESC/, cur[3]); - item = item.replace(/_USER/, cur[4]); - item = item.replace(/_DATE/, cur[5]); var tagspan = ''; if (cur[7].length || cur[8].length || (cur[6][0] != 'default' || cur[6][1])) \{ @@ -108,8 +97,11 @@ } tagspan += '</span>'; } + + var item = '<li style="' + nstyle + '"><span class="desc">'; + item += '<a href="{url}rev/' + cur[0] + '{sessionvars%urlparameter}" title="' + cur[0] + '">' + cur[3] + '</a>'; + item += '</span>' + tagspan + '<span class="info">' + cur[5] + ', by ' + cur[4] + '</span></li>'; - item = item.replace(/_TAGS/, tagspan); return [bg, item]; }
--- a/mercurial/templates/spartan/graph.tmpl Wed Aug 29 13:16:56 2012 -0500 +++ b/mercurial/templates/spartan/graph.tmpl Wed Aug 29 02:09:43 2012 +0200 @@ -43,10 +43,6 @@ var graph = new Graph(); graph.scale({bg_height}); -var revlink = '<li style="_STYLE"><span class="desc">'; -revlink += '<a href="{url}rev/_NODEID{sessionvars%urlparameter}" title="_NODEID">_DESC</a>'; -revlink += '</span><span class="info">_DATE, by _USER</span></li>'; - graph.vertex = function(x, y, color, parity, cur) \{ this.ctx.beginPath(); @@ -57,14 +53,10 @@ var bg = '<li class="bg parity' + parity + '"></li>'; var left = (this.columns + 1) * this.bg_height; var nstyle = 'padding-left: ' + left + 'px;'; - var item = revlink.replace(/_STYLE/, nstyle); - item = item.replace(/_PARITY/, 'parity' + parity); - item = item.replace(/_NODEID/, cur[0]); - item = item.replace(/_NODEID/, cur[0]); - item = item.replace(/_DESC/, cur[3]); - item = item.replace(/_USER/, cur[4]); - item = item.replace(/_DATE/, cur[5]); - + var item = '<li style="' + nstyle + '"><span class="desc">'; + item += '<a href="{url}rev/' + cur[0] + '{sessionvars%urlparameter}" title="' + cur[0] + '">' + cur[3] + '</a>'; + item += '</span><span class="info">' + cur[5] + ', by ' + cur[4] + '</span></li>'; + return [bg, item]; }
--- a/tests/test-hgweb-commands.t Wed Aug 29 13:16:56 2012 -0500 +++ b/tests/test-hgweb-commands.t Wed Aug 29 02:09:43 2012 +0200 @@ -980,11 +980,6 @@ var graph = new Graph(); graph.scale(39); - var revlink = '<li style="_STYLE"><span class="desc">'; - revlink += '<a class="list" href="/rev/_NODEID?style=gitweb" title="_NODEID"><b>_DESC</b></a>'; - revlink += '</span> _TAGS'; - revlink += '<span class="info">_DATE, by _USER</span></li>'; - graph.vertex = function(x, y, color, parity, cur) { this.ctx.beginPath(); @@ -995,13 +990,6 @@ var bg = '<li class="bg parity' + parity + '"></li>'; var left = (this.columns + 1) * this.bg_height; var nstyle = 'padding-left: ' + left + 'px;'; - var item = revlink.replace(/_STYLE/, nstyle); - item = item.replace(/_PARITY/, 'parity' + parity); - item = item.replace(/_NODEID/, cur[0]); - item = item.replace(/_NODEID/, cur[0]); - item = item.replace(/_DESC/, cur[3]); - item = item.replace(/_USER/, cur[4]); - item = item.replace(/_DATE/, cur[5]); var tagspan = ''; if (cur[7].length || cur[8].length || (cur[6][0] != 'default' || cur[6][1])) { @@ -1028,7 +1016,11 @@ tagspan += '</span>'; } - item = item.replace(/_TAGS/, tagspan); + var item = '<li style="' + nstyle + '"><span class="desc">'; + item += '<a class="list" href="/rev/' + cur[0] + '?style=gitweb" title="' + cur[0] + '"><b>' + cur[3] + '</b></a>'; + item += '</span> ' + tagspan + ''; + item += '<span class="info">' + cur[5] + ', by ' + cur[4] + '</span></li>'; + return [bg, item]; }
--- a/tests/test-hgweb-empty.t Wed Aug 29 13:16:56 2012 -0500 +++ b/tests/test-hgweb-empty.t Wed Aug 29 02:09:43 2012 +0200 @@ -250,10 +250,6 @@ var graph = new Graph(); graph.scale(39); - var revlink = '<li style="_STYLE"><span class="desc">'; - revlink += '<a href="/rev/_NODEID" title="_NODEID">_DESC</a>'; - revlink += '</span>_TAGS<span class="info">_DATE, by _USER</span></li>'; - graph.vertex = function(x, y, color, parity, cur) { this.ctx.beginPath(); @@ -264,13 +260,6 @@ var bg = '<li class="bg parity' + parity + '"></li>'; var left = (this.columns + 1) * this.bg_height; var nstyle = 'padding-left: ' + left + 'px;'; - var item = revlink.replace(/_STYLE/, nstyle); - item = item.replace(/_PARITY/, 'parity' + parity); - item = item.replace(/_NODEID/, cur[0]); - item = item.replace(/_NODEID/, cur[0]); - item = item.replace(/_DESC/, cur[3]); - item = item.replace(/_USER/, cur[4]); - item = item.replace(/_DATE/, cur[5]); var tagspan = ''; if (cur[7].length || cur[8].length || (cur[6][0] != 'default' || cur[6][1])) { @@ -296,8 +285,11 @@ } tagspan += '</span>'; } + + var item = '<li style="' + nstyle + '"><span class="desc">'; + item += '<a href="/rev/' + cur[0] + '" title="' + cur[0] + '">' + cur[3] + '</a>'; + item += '</span>' + tagspan + '<span class="info">' + cur[5] + ', by ' + cur[4] + '</span></li>'; - item = item.replace(/_TAGS/, tagspan); return [bg, item]; }