r75470 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75469‎ | r75470 | r75471 >
Date:20:46, 26 October 2010
Author:kaldari
Status:reverted (Comments)
Tags:
Comment:
using encodeURIComponent is unneccessary since the text gets escaped anyway
Modified paths:
  • /trunk/extensions/CentralNotice/SpecialBannerController.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/SpecialBannerController.php
@@ -69,7 +69,7 @@
7070 var geoLocation = Geo.country; // pull the geo info
7171 }
7272 var bannerListQuery = $.param( { 'language': wgContentLanguage, 'project': wgNoticeProject, 'country': geoLocation } );
73 - var bannerListURL = wgScript + '?title=' + encodeURIComponent(wgFormattedNamespaces[-1]) + ':BannerListLoader&cache=/cn.js&' + bannerListQuery;
 73+ var bannerListURL = wgScript + '?title=' + wgFormattedNamespaces[-1] + ':BannerListLoader&cache=/cn.js&' + bannerListQuery;
7474 var request = $.ajax( {
7575 url: bannerListURL,
7676 dataType: 'json',

Follow-up revisions

RevisionCommit summaryAuthorDate
r75889fix for r75470kaldari23:22, 2 November 2010

Comments

#Comment by TheDJ (talk | contribs)   14:47, 30 October 2010

Hmm, this doesn't seem logical to me. This would mean 2 things. 1 relying on the ajax routines to detect the proper parts in the url to encode, and 2 it means you are not passing a valid URI to ajax. All components in the data option of .ajax are indeed encoded by .ajax, but passing invalid uri's to the url param doesn't seem like a good idea to me.

#Comment by Kaldari (talk | contribs)   19:36, 30 October 2010

Since wgFormattedNamespaces never contains reserved characters anyway, I think it's probably a moot issue. I did notice, however, that special (non-ASCII) characters are being escaped regardless. For example, "Spécial" always ends up as "Sp%C3%A9cial" in the resulting URL regardless of whether I use encodeURIComponent(), so I just assumed the same would be true of reserved characters. I don't actually know that this is the case, however, so you could be right. But like I said, since wgFormattedNamespaces is defined in the source (not from a query string parameter) and it never contains reserved URI characters (as far as I can tell), it probably doesn't matter anyway. If you think it should be changed back, though, just let me know. I'm not married to it either way.

#Comment by TheDJ (talk | contribs)   19:43, 30 October 2010

It probably won't break indeed, but I've seen so many issues around this, that I prefer doing it properly. However, if you are already adding query params using bannerlistQuery, then why add other query params by hand to bannerListUrl ?

#Comment by Kaldari (talk | contribs)   06:00, 31 October 2010

I need the slash unescaped for the squid regex.

#Comment by Kaldari (talk | contribs)   23:23, 2 November 2010

reverted in r75889.

Status & tagging log