[rfc][icedtea-web] Replace single quote with two single quotes when using MessageFormat in Translator
Jacob Wisor
gitne at gmx.de
Mon Mar 16 21:16:45 UTC 2015
On 03/16/2015 09:31 PM CET Jie Kang wrote:
>
>
> ----- Original Message -----
>> On 03/16/2015 07:20 PM CET Jie Kang wrote:
>>> ----- Original Message -----
>>>> On 03/16/2015 05:32 PM CET Jie Kang wrote:
>>>>> ----- Original Message -----
>>>>>> Hello,
>>>>>>
>>>>>> When looking into reproducer failures I noticed that the single quote '
>>>>>> was
>>>>>> not being displayed in the logs.
>>>>>>
>>>>>> E.g:
>>>>>>
>>>>>> don't --> dont
>>>>>>
>>>>>> This was caused by the use of MessageFormat in the Translator class.
>>>>>>
>>>>>> From [1]: Within a String, "''" represents a single quote. [...]
>>>>>>
>>>>>> [1]
>>>>>> http://docs.oracle.com/javase/6/docs/api/java/text/MessageFormat.html
>>>>>>
>>>>>> Out of the various possible fixes, I have decided to replace single
>>>>>> quote
>>>>>> instances with two quotes only prior to using the MessageFormat class.
>>>>>> Afaict, this doesn't cause any issues and doesn't affect things that
>>>>>> don't
>>>>>> go through the MessageFormat class.
>>>>>>
>>>>>> This bug caused a number of reproducers to fail (ex.
>>>>>> CodeBaseManifestEntryUnsignedNotMatching.BrowserJNLPHrefRemoteTest) as
>>>>>> they
>>>>>> expected a string like "don't" but the log output contained a string
>>>>>> "dont".
>>>>>> With this fix, those reproducers now pass.
>>>>>>
>>>>>> Thoughts?
>>>>
>>>> Hmm, the solution to this problem actually depends on the coding style of
>>>> message property files. For example, OpenJDK works around this issue is by
>>>> actually putting double apostrophe characters into their tool's message
>>>> property
>>>> files. So, IcedTea-Web should have or decide on some sort of coding style
>>>> for
>>>> its message property files. Which one should it be is arguable. Your
>>>> approach
>>>> is
>>>> certainly valid, however whether it also acceptable depends on the coding
>>>> style
>>>> for message property files in IcedTea-Web. Personally, I would prefer
>>>> OpenJDK's
>>>> approach, hence modify the property files and do not get into possibly
>>>> error
>>>> prone mangling of strings.
>>>
>>> I prefer users of the property files not having to deal with how the code
>>> formats the strings. I don't care which method goes in as long as one goes
>>> in so I'll wait for a third opinion.
>>
>> I understand and I would like this to happen too. However, you would also
>> have
>> to provide for proper handling of explicit occurrences of curly brackets
>> (U+007B
>> and U+007D). I am sure we do not want to get into this game.
>
> Sure. Patch attached. Comments have been added to Messages.properties. I chose to keep the test for apostrophe escaping and modified it appropriately. That way if someone modifies this later it'll fail and hopefully point them towards fixing the properties files as well.
>
> I used:
>
> sed -i "s/'/''/g" $file
>
> to change all the properties files.
>
> Seems fine after a cursory examination.
>
> How does it look?
Looks okay. I am still a little bit concerned about messages like
MissingPermissionsMainTitle or ALACAMissingMainTitle which contain HTML elements
with attribute values in apostrophes. Could you please test manually
specifically for those messages, that is whether they are processed correctly by
the swing framework?
Jacob
More information about the distro-pkg-dev
mailing list