rquinio / l10n-maven-plugin

:abcd: Maven plugin to validate localization resources in Java properties files
MIT License
3 stars 1 forks source link

False-positive non escaped quote ' when inside curly brackets #10

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
From version <= l10n-maven-plugin:1.7

Hi,

An error is trigger for non escaped ' character, within a curly bracket, where 
it is actually allowed.

Example :
app.form.profile.results.pending.hint={0} made his reservation on 
{0,date,MM/dd/yyyy HH':'mm}

[ERROR] 
<messages_en.properties><app.form.main.profile.journeys.results.pending.hint> 
MessageFormat requires that ' be escaped with ''.
Property value was:[{0} made his reservation on {0,date,MM/dd/yyyy HH':'mm}]

But the point is that quote character have not to be escaped in a statement 
wrapped in burly brackets.

app.form.profile.results.pending.hint={0} made his reservation on 
{0,date,MM/dd/yyyy HH':'mm}
--> outputs : Thomas made his reservation on 05/21/2014 23:53

but :
app.form.profile.results.pending.hint={0} made his reservation on 
{0,date,MM/dd/yyyy HH':'mm}
--> outputs : Thomas made his reservation on 05/21/2014 23':'53

Please ignore non escaped quotes for strings inside curly brackets.

Thanks.
Saad Benbouzid

Original issue reported on code.google.com by Makaveli...@gmail.com on 21 May 2014 at 9:55

GoogleCodeExporter commented 9 years ago
Please modify your regex as consequence :) In order to ignore non escapted 
quote within a curly bracket.

(.*[^']'[^'].*|^'[^'].*|.*[^']'$)

from 
<com.googlecode.l10nmavenplugin.validators.property.format.MessageFormatFormatti
ngValidator>

Thanks.

Original comment by Makaveli...@gmail.com on 26 May 2014 at 5:45

GoogleCodeExporter commented 9 years ago
Good point, this datetime pattern is a frequent usage of escaping.

Currently unescaped single quotes are not supported both:
- Outside parameter: it's usually a mistake, unless wanting to output something 
like '{' ^^
- Inside, in a SubformatPattern: it'll need to be ignored or validated 
separately.

Original comment by romain.q...@gmail.com on 7 Jul 2014 at 10:54