https://bugzilla.wikimedia.org/show_bug.cgi?id=59681

       Web browser: ---
            Bug ID: 59681
           Summary: collection extension doesn't convert URL to unicode
           Product: MediaWiki extensions
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: Unprioritized
         Component: Collection
          Assignee: wikibugs-l@lists.wikimedia.org
          Reporter: reza.ene...@gmail.com
                CC: developm...@pediapress.com, marcin.cies...@gmail.com
    Classification: Unclassified
   Mobile Platform: ---

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

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
Wikibugs-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to