AnantLabs / rdfquery

Automatically exported from code.google.com/p/rdfquery
0 stars 0 forks source link

Can't parse RDFa literals containing double quotes #30

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
When serializing a string into the turtle syntax for a literal, double quotes 
must be escaped.

On the following lines they are not.
http://code.google.com/p/rdfquery/source/browse/tags/v1.0/jquery.rdfa.js?r=193#3
78
http://code.google.com/p/rdfquery/source/browse/tags/v1.0/jquery.rdfa.js?r=193#3
86

Replace this:

object = $.rdf.literal('"' + content + '"');

With this:

object = $.rdf.literal('"' + content.replace(/\\/g, "\\\\").replace(/"/g, 
'\\"') + '"');

Original issue reported on code.google.com by james-no...@leighnet.ca on 5 Jan 2011 at 6:41

GoogleCodeExporter commented 9 years ago
And in a highly related issue, when parsing rdf/xml, it fails when the string 
value contains double quotes.

Original comment by azarot...@gmail.com on 24 Jun 2011 at 11:31

GoogleCodeExporter commented 9 years ago
And in a highly related fix, when parsing rdf/xml:

Replace this:
object = $.rdf.literal(literalOpts.lang ? o : '"' + o + '"', literalOpts);

With this:
object = $.rdf.literal(literalOpts.lang ? o : '"' + o.replace(/"/g, '\\"') + 
'"', literalOpts);

Original comment by jman...@gmail.com on 28 Jul 2011 at 12:50