pietercolpaert / hardf

Low level PHP library for RDF1.1 based on N3.js
https://packagist.org/packages/pietercolpaert/hardf
MIT License
36 stars 7 forks source link

Util::getLiteralValue() fails for multiline values #33

Closed zozlak closed 3 years ago

zozlak commented 3 years ago

The regullar expression in https://github.com/pietercolpaert/hardf/blob/master/src/Util.php#L64 doesn't match multiline values, e.g.

pietercolpaert\hardf\Util::getLiteralValue('"' . "foo\nbar" . '"');

throws an error instead of returning

foo
bar

I think the fix is to add m and s flags (see here) to the regex making https://github.com/pietercolpaert/hardf/blob/master/src/Util.php#L64:

preg_match('/^"(.*)"/sm', $literal, $match); //TODO: somehow the copied regex did not work. To be checked. Contained [^]