I found a number of troubles when trying to replicate localurl: parser function by python urllib.quote(), with a number of annoying bugs.
Is this correct-complete?
"/wiki/"+urllib.quote(name-of-page.replace(" ","_"),"/!,;:.-_") where name-of-page is utf-8 encoded.
Thanks! I apologyze for so a banal question.
Alex brollo
Alex Brollo wrote:
I found a number of troubles when trying to replicate localurl: parser function by python urllib.quote(), with a number of annoying bugs.
Is this correct-complete?
"/wiki/"+urllib.quote(name-of-page.replace(" ","_"),"/!,;:.-_") where name-of-page is utf-8 encoded.
Thanks! I apologyze for so a banal question.
Alex brollo
The relevant function is Title::getLocalURL() I think that in your quote function you need to skip '@$*(),' as well, and ".-_" wouldn't be needed there (but urllib.quote could differ from php urlencode). See wfUrlEncode in GlobalFunctions.php
2011/6/27 Platonides Platonides@gmail.com
The relevant function is Title::getLocalURL() I think that in your quote function you need to skip '@$*(),' as well, and ".-_" wouldn't be needed there (but urllib.quote could differ from php urlencode). See wfUrlEncode in GlobalFunctions.php
Thanks Platonidea, I'll test localurl for your character list. In the meantime, I found that my one was a rather silly question since any html link to wiki pages from mediawiki software has this kind of code:
<a href="/wiki/Portal:Children%27s_literature" title="Portal:Children's literature">Portal:Children's literature</a>.
t.i., there is both the escaped version of the title of the page into href attribute, and the not-escaped version of the name of the page, inside the title attribute; the latter being mush simpler as a key to select links. :-)
Alex
On 27/06/11 23:14, Platonides wrote:
See wfUrlEncode in GlobalFunctions.php
I have added tests for this function with r91108. Feel free to propose additional tests :)
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/91108
2011/6/29 Ashar Voultoiz hashar+wmf@free.fr
On 27/06/11 23:14, Platonides wrote:
See wfUrlEncode in GlobalFunctions.php
I have added tests for this function with r91108. Feel free to propose additional tests :)
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/91108
-- Ashar Voultoiz
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
I tested too mediaWiki encoding with js encodeURI() function. I found a difference, only one, since mediaWiki encodes apostrophe while encodeURI() doesn't. Obviously the second, great difference is the conversion of spaces into underlines.
So, in js so far I got a good simulation of localurl: Mediawiki encoding with this: encodeURI(string.replace(/ /g,"_")).replace(/%27/g,"'") )
(the last string is an apostrophe between double quotes)
Is there some reason why wiki encoding is different from js encodeURI (that, I presume, is founded on a standard)? I found this a little confusing.
Alex
On Wed, Jun 29, 2011 at 19:42, Alex Brollo alex.brollo@gmail.com wrote:
Is there some reason why wiki encoding is different from js encodeURI (that, I presume, is founded on a standard)? I found this a little confusing.
Me too. And it gets more confusing with the addition of mw.util.rawurlencode and mw.util.wikiUrlencode: http://www.mediawiki.org/wiki/ResourceLoader/Default_modules#rawurlencode http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/resources/mediawiki/m...
Helder
wikitech-l@lists.wikimedia.org