GithubHelp home page GithubHelp logo

Comments (5)

RubenVerborgh avatar RubenVerborgh commented on May 13, 2024

In SPARQL literals, \\ is an escape sequence for a single backslash \. Therefore, the string "@work\\.example$" has contents @work\.example$, so the latter is the correct result.

It also makes sense: in example 17.4.2.5 of the SPARQL spec, the purpose of the regex is to match <mailto:[email protected]>. In other words, the (single) backslash serves to escape the dot.

So the output is correct as far as I understand.

from sparql.js.

yamalight avatar yamalight commented on May 13, 2024

@RubenVerborgh the problem here is that when you unescape "\"@work\\.example$\"" you'll get "@work\.example$" which differs from original SPARQL which looks like "@work\\.example$".
Which means that my generated queries will always be wrong here. So, that does looks like a bug to me. \\ should be escaped to \\\\ during parsing, then when unescaping back it will become \\ which is exactly what was there originally.

from sparql.js.

RubenVerborgh avatar RubenVerborgh commented on May 13, 2024

I still think it's the same.

Language Literal in language syntax Interpretation (actual characters inside literal)
SPARQL "@work\\.example$" @work\.example$
JavaScript '"@work\\.example$"' "@work\.example$"

Note how the interpretation is the same in both languages (but the N3.js wraps all literals in double quotes).

In order to convert from the representation to SPARQL, you will need to escape the backslash.

Note that you generally never escape during parsing: parsing means unescaping, generating means escaping. (See for instance how we parse URLs.)

from sparql.js.

yamalight avatar yamalight commented on May 13, 2024

Hmm.. Makes sense! Good, then I'll escape backslashes specifically during query generation.

from sparql.js.

RubenVerborgh avatar RubenVerborgh commented on May 13, 2024

Yeah, that's probably something that needs to be done for all literal generation, because backslashes have special meaning.

from sparql.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.