hgweb: stop using HTML comments in <script>
Once upon a time, in 1995, there were browsers that didn't understand <script>
tags and they would simply show the code inside as text. This started a
tradition of wrapping everything inside <script> in <!-- HTML comments -->.
Nowadays, it's not only not needed, but can be considered harmful[1]:
- within XHTML documents, the source will actually be hidden from all browsers
and rendered useless
- `--` is not allowed within HTML comments, so any decrement operations in
script are invalid
[1]: http://www.javascripttoolbox.com/bestpractices/#comments
--- a/mercurial/templates/gitweb/graph.tmpl Thu Dec 14 16:01:28 2017 -0500
+++ b/mercurial/templates/gitweb/graph.tmpl Fri Dec 15 12:15:58 2017 +0800
@@ -43,8 +43,6 @@
</div>
<script{if(nonce, ' nonce="{nonce}"')}>
-<!-- hide script content
-
var data = {jsdata|json};
var graph = new Graph();
graph.scale({bg_height});
@@ -55,8 +53,6 @@
}
graph.render(data);
-
-// stop hiding script -->
</script>
<div class="extra_nav">
--- a/mercurial/templates/monoblue/graph.tmpl Thu Dec 14 16:01:28 2017 -0500
+++ b/mercurial/templates/monoblue/graph.tmpl Fri Dec 15 12:15:58 2017 +0800
@@ -35,8 +35,6 @@
</div>
<script{if(nonce, ' nonce="{nonce}"')}>
- <!-- hide script content
-
document.getElementById('noscript').style.display = 'none';
var data = {jsdata|json};
@@ -49,8 +47,6 @@
}
graph.render(data);
-
- // stop hiding script -->
</script>
<div class="page-path">
--- a/mercurial/templates/paper/graph.tmpl Thu Dec 14 16:01:28 2017 -0500
+++ b/mercurial/templates/paper/graph.tmpl Fri Dec 15 12:15:58 2017 +0800
@@ -56,8 +56,6 @@
</div>
<script type="text/javascript"{if(nonce, ' nonce="{nonce}"')}>
-<!-- hide script content
-
var data = {jsdata|json};
var graph = new Graph();
graph.scale({bg_height});
@@ -68,8 +66,6 @@
}
graph.render(data);
-
-// stop hiding script -->
</script>
<div class="navigate">
--- a/mercurial/templates/spartan/graph.tmpl Thu Dec 14 16:01:28 2017 -0500
+++ b/mercurial/templates/spartan/graph.tmpl Fri Dec 15 12:15:58 2017 +0800
@@ -37,8 +37,6 @@
</div>
<script type="text/javascript"{if(nonce, ' nonce="{nonce}"')}>
-<!-- hide script content
-
var data = {jsdata|json};
var graph = new Graph();
graph.scale({bg_height});
@@ -49,8 +47,6 @@
}
graph.render(data);
-
-// stop hiding script -->
</script>
<form action="{url|urlescape}log">
--- a/tests/test-hgweb-commands.t Thu Dec 14 16:01:28 2017 -0500
+++ b/tests/test-hgweb-commands.t Fri Dec 15 12:15:58 2017 +0800
@@ -1814,8 +1814,6 @@
</div>
<script>
- <!-- hide script content
-
var data = [{"edges": [[0, 0, 1, 3, "FF0000"]], "node": "cad8025a2e87", "vertex": [0, 1]}, {"edges": [[0, 0, 1, 3, ""]], "node": "1d22e65f027e", "vertex": [0, 1]}, {"edges": [[0, 0, 1, 3, ""]], "node": "a4f92ed23982", "vertex": [0, 1]}, {"edges": [], "node": "2ef0ac749a14", "vertex": [0, 1]}];
var graph = new Graph();
graph.scale(39);
@@ -1826,8 +1824,6 @@
}
graph.render(data);
-
- // stop hiding script -->
</script>
<div class="extra_nav">
--- a/tests/test-hgweb-empty.t Thu Dec 14 16:01:28 2017 -0500
+++ b/tests/test-hgweb-empty.t Fri Dec 15 12:15:58 2017 +0800
@@ -300,8 +300,6 @@
</div>
<script type="text/javascript">
- <!-- hide script content
-
var data = [];
var graph = new Graph();
graph.scale(39);
@@ -312,8 +310,6 @@
}
graph.render(data);
-
- // stop hiding script -->
</script>
<div class="navigate">