Add escaping to N-Quads.

This commit is contained in:
Dave Longley 2012-05-13 16:31:11 -04:00
parent 00c18e853e
commit 5149bf383c

View file

@ -937,7 +937,11 @@ class JsonLdProcessor {
$s->object->interfaceName = 'BlankNode';
}
else {
$s->object->nominalValue = $match[6];
$unescaped = str_replace(
array('\"', '\t', '\n', '\r', '\\\\'),
array('"', "\t", "\n", "\r", '\\'),
$match[6]);
$s->object->nominalValue = $unescaped;
$s->object->interfaceName = 'LiteralNode';
if(isset($match[7]) && $match[7] !== '') {
$s->object->datatype = (object)array(
@ -1013,7 +1017,11 @@ class JsonLdProcessor {
}
}
else {
$quad .= '"' . $o->nominalValue . '"';
$escaped = str_replace(
array('\\', "\t", "\n", "\r", '"'),
array('\\\\', '\t', '\n', '\r', '\"'),
$o->nominalValue);
$quad .= '"' . $escaped . '"';
if(property_exists($o, 'datatype')) {
$quad .= "^^<{$o->datatype->nominalValue}>";
}