forked from friendica/php-json-ld
Add escaping to N-Quads.
This commit is contained in:
parent
00c18e853e
commit
5149bf383c
12
jsonld.php
12
jsonld.php
|
@ -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}>";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue