weixunjie / jquery-i18n-properties

Automatically exported from code.google.com/p/jquery-i18n-properties
0 stars 0 forks source link

Problem parsing multi-line properties with multiple '=' sign #1

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
From Sergei:

This is really great plugin, but I’ve found a problem when parsing multi-line 
properties like this:

{{{
test = You know that 2×2=5 is incorrect, \
correct answer is 4
}}}

you’re using split() to get the pairs, but in this case it will split to *3* 
values and thus you’ll get syntax error on final eval().
Probably, the split() should be either replaced by regex or there should be 
condition like: if (pair.length > 2) – concatenate everything else to 
pairs[1].
 ---

I’m not JS guru, so this is probably not so elegant solution, but it works. 
I’ve replaced in jquery.i18n.properties.js@130

{{{var pair = parameters[i].split(‘=’);}}}

by
{{{
var pair_regexp = /^([^=] )=(.*)$/im;
var pair = pair_regexp.exec(parameters[i]);
pair.shift();
}}}
to resolve the problem above with “=” inside the message text.

Original issue reported on code.google.com by nfgr...@gmail.com on 22 May 2011 at 11:30

GoogleCodeExporter commented 8 years ago
In Java properties files several formats of key value separators are possible:
key=value
key = value
key value
key:value

A second equals character in a key value pair is not valid in Java properties 
files. You'll have to escape it. See 
http://download.oracle.com/javase/6/docs/api/java/util/Properties.html#load(java
.io.Reader)

Original comment by grosse_j...@yahoo.de on 28 May 2011 at 4:50

GoogleCodeExporter commented 8 years ago
I think the Reader doc specifies that you can escape "=" signs in the *key* ; 
in this case this is about escaping it in the *value* (which I don't think is 
required, unless I read wrong...)

Besides, escaping the "=" sign does not solve the issue, in my case...

Original comment by phtriv...@gmail.com on 5 Nov 2013 at 3:21