forked from friendica/php-json-ld
Add escaping to N-Quads.
This commit is contained in:
parent
00c18e853e
commit
5149bf383c
1 changed files with 20 additions and 12 deletions
12
jsonld.php
12
jsonld.php
|
@ -937,7 +937,11 @@ class JsonLdProcessor {
|
||||||
$s->object->interfaceName = 'BlankNode';
|
$s->object->interfaceName = 'BlankNode';
|
||||||
}
|
}
|
||||||
else {
|
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';
|
$s->object->interfaceName = 'LiteralNode';
|
||||||
if(isset($match[7]) && $match[7] !== '') {
|
if(isset($match[7]) && $match[7] !== '') {
|
||||||
$s->object->datatype = (object)array(
|
$s->object->datatype = (object)array(
|
||||||
|
@ -1013,7 +1017,11 @@ class JsonLdProcessor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$quad .= '"' . $o->nominalValue . '"';
|
$escaped = str_replace(
|
||||||
|
array('\\', "\t", "\n", "\r", '"'),
|
||||||
|
array('\\\\', '\t', '\n', '\r', '\"'),
|
||||||
|
$o->nominalValue);
|
||||||
|
$quad .= '"' . $escaped . '"';
|
||||||
if(property_exists($o, 'datatype')) {
|
if(property_exists($o, 'datatype')) {
|
||||||
$quad .= "^^<{$o->datatype->nominalValue}>";
|
$quad .= "^^<{$o->datatype->nominalValue}>";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue