From c3d27352e1ac21e381f3f60515352081f3648030 Mon Sep 17 00:00:00 2001 From: Hadrien Date: Wed, 8 Jun 2022 16:41:00 +0100 Subject: [PATCH] N3Parser: support escape sequences in local names Allow local name to use escape sequences as per https://www.w3.org/TR/turtle/#sec-escapes --- src/n3parser.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/n3parser.js b/src/n3parser.js index 2954e4b3e..c3dcdb21b 100644 --- a/src/n3parser.js +++ b/src/n3parser.js @@ -1244,12 +1244,22 @@ export class SinkParser { var ln = ""; while ((i < pyjslib_len(str))) { var c = str.charAt(i); - if ((_notNameChars.indexOf(c) < 0)) { - var ln = ( ln + c ) ; - var i = ( i + 1 ) ; - } - else { - break; + if (c ==='\\'){ + var c2 = str.charAt(i+1) + if ((_notNameChars.indexOf(c2) >= 0)) { + var ln = ( ln + c2 ) ; + var i = ( i + 2 ) ; + } + else { + break; + } + } else { + if ((_notNameChars.indexOf(c) < 0)) { + var ln = (ln + c); + var i = (i + 1); + } else { + break; + } } } res.push(new pyjslib_Tuple([pfx, ln]));