git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/4] gitweb: Don't append ';js=(0|1)' to external links

From
Jakub Narębski <jnareb@gmail.com>
Date
Apr 9, 2013, 15:16 UTC
Message-ID
<516430D5.6030201@gmail.com>
In-Reply-To
<m2wqscbx83.fsf@blackdown.de>
Jürgen Kreileder wrote:
> Don't add js parameters to links outside of gitweb itself.

Hmmm... this limits adding ';js=(0|1)' to only links which begin with $my_url, i.e. absolute links beginning with gitweb's base URL.

Wouldn't that mean that most internal gitweb-generated links wouldn't get ';js=(0|1)'? href(..., -full => 1) is not the default...

Show 38 quoted lines
> Signed-off-by: Jürgen Kreileder <jk@blackdown.de>
> ---
>  gitweb/gitweb.perl                       |    2 +-
>  gitweb/static/js/javascript-detection.js |    4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index 1309196..f0912d7 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -4165,7 +4165,7 @@ sub git_footer_html {
>  		print qq!<script type="text/javascript">\n!.
>  		      qq!window.onload = function () {\n!;
>  		if (gitweb_check_feature('javascript-actions')) {
> -			print qq!	fixLinks();\n!;
> +			print qq!	fixLinks('$my_url');\n!;
>  		}
>  		if ($jstimezone && $tz_cookie && $datetime_class) {
>  			print qq!	var tz_cookie = { name: '$tz_cookie', expires: 14, path: '/' };\n!. # in days
> diff --git a/gitweb/static/js/javascript-detection.js b/gitweb/static/js/javascript-detection.js
> index fa2596f..36964ad 100644
> --- a/gitweb/static/js/javascript-detection.js
> +++ b/gitweb/static/js/javascript-detection.js
> @@ -29,11 +29,11 @@ var jsExceptionsRe = /[;?]js=[01](#.*)?$/;
>   *
>   * @globals jsExceptionsRe
>   */
> -function fixLinks() {
> +function fixLinks(baseurl) {
>  	var allLinks = document.getElementsByTagName("a") || document.links;
>  	for (var i = 0, len = allLinks.length; i < len; i++) {
>  		var link = allLinks[i];
> -		if (!jsExceptionsRe.test(link)) {
> +		if (!jsExceptionsRe.test(link) && !link.href.indexOf(baseurl)) {
>  			link.href = link.href.replace(/(#|$)/,
>  				(link.href.indexOf('?') === -1 ? '?' : ';') + 'js=1$1');
>  		}
> 
-- 
Jakub Narębski
Previous: Jürgen KreilederNext: Jürgen Kreileder
Message 2 of 4 in “gitweb: Don't append ';js=(0|1)' to external links”
  1. 3/4 gitweb: Don't append ';js=(0|1)' to external linksJürgen Kreileder, Apr 8, 2013
  2. Jakub NarębskiApr 9, 2013
  3. Jürgen KreilederApr 9, 2013
  4. Jakub NarębskiApr 9, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.