Page MenuHomePhabricator

tools.chars.url2string() fails even a valid encoding is given
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue:

from pywikibot.tools.chars import url2string
url2string('El%20Ni%C3%B1o', ['ascii', 'utf-8'])

`What happens?:

Traceback (most recent call last):
  File "<pyshell#82>", line 1, in <module>
    url2string('/El%20Ni%C3%B1o/', ['ascii', 'utf-8'])
  File "D:\pwb\GIT\core\pywikibot\tools\chars.py", line 130, in url2string
    return t.decode(enc)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 6: ordinal not in range(128)

What should have happened instead?:
'El Niño' should be given

Details

Event Timeline

Xqt triaged this task as High priority.Apr 22 2023, 4:26 PM

Change 910826 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [bugfix] Fix url2string parsing for multiple encodings

https://gerrit.wikimedia.org/r/910826

Xqt changed the task status from Open to In Progress.Apr 22 2023, 4:59 PM
Xqt claimed this task.

Change 910826 merged by jenkins-bot:

[pywikibot/core@master] [bugfix] Fix url2string parsing for multiple encodings

https://gerrit.wikimedia.org/r/910826