Page MenuHomePhabricator

Android exporter causes build failure due to presence of '%' in generated xml
Open, MediumPublic

Description

Found this with the 'about_privacy_policy' string; cs and gl versions were added with %-encoding for some chars in the URL.

This triggered a compilation error in resources:

error: Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute?

Worked around here by simply replacing the % codes with their original chars, since that works for them:
[2:07pm] wikipedia-github: android-commons/master a28fc9a Brion Vibber: Work around compilation failure with % encoding in strings
with the same fixes copied over to TWN and a qqq entry added describing the issue.

Proper fix for this is to add formatted="no" attribute to the <string> entry. So we'd maybe need to set it on the original and make sure it gets passed through to the translated outputs....?

Alternate fix is to use %%... or perhaps to redo it as a formatted string and figure out how to get those to round-trip through TWN.


Version: unspecified
Severity: normal

Details

Reference
bz49412

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 2:06 AM
bzimport set Reference to bz49412.
bzimport added a subscriber: Unknown Object (MLST).

/me wonders how such many annoying things ended up in one file format.

It's the lovechild of XML and Java, so...

Brion and Yuvi, I've added this bug to https://www.mediawiki.org/wiki/Mentorship_programs/Possible_projects#Extensive_and_robust_localisation_file_format_coverage. Would you be able to help a student by reviewing contributions such as a patch for this bug? If yes please add yourself there as co-mentor, then we'll be able to mark it featured.

Hi. Could somebody help me on how to reproduce this bug on a wiki that is newly setup?

Hi. Could somebody help me on how to reproduce this bug on a wiki that is newly setup?

See https://phabricator.wikimedia.org/rAPACa28fc9a6ffc7f4175578f1b5f7f18a2eaf438f4f#C155395NL55 : you should be able to add for translation a software which uses XML strings, and test the bug by adding messages which contain a % sign. See https://phabricator.wikimedia.org/diffusion/GTWN/browse/master/groups/Wikimedia/WikimediaMobile-android.yaml for a configuration example.

We now have validators for this kind of thing. Just needs to be set up.

Moving back to Translate. I don't see a premade validator for this. Printf validator doesn't prevent invalid strings.