Last modified: 2014-01-05 14:55:29 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T61681, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 59681 - collection extension doesn't convert URL to unicode
collection extension doesn't convert URL to unicode
Status: NEW
Product: MediaWiki extensions
Classification: Unclassified
Collection (Other open bugs)
unspecified
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-01-05 14:53 UTC by reza1615
Modified: 2014-01-05 14:55 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description reza1615 2014-01-05 14:53:56 UTC
I made a simple test in 
http://en.wikipedia.org/wiki/User:Yamaha5/pdf
as you see both are them are the same URL but the first is percentage URL and it should better that collection extension before rendering convert them to Unicode.

Convertor Code in python (mediawiki has problem with {|} space which are in URLs so I replaced them with percentage one)


import urllib

def UnicodeURL(text):
    old_text=text
    RE=re.compile(ur'\/\/.*?(?=[\s\n\|\}\]]|$)')
    fa_Urls=RE.findall(text)
    if fa_Urls:
        for URL in fa_Urls:
            try:
                URL=URL.split('<')[0]
                new_URL=urllib.unquote(URL.encode('utf8')).decode('utf8').replace(u' ',u'%20').replace(u'{',u'%7B').replace(u'|',u'%7C').replace(u'}',u'%7D')
                text=text.replace(URL,new_URL)
            except:
                continue
    return text

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links