Skip to content

Improve verification of DOM string IRI #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
object opened this issue Mar 10, 2014 · 2 comments
Closed

Improve verification of DOM string IRI #2

object opened this issue Mar 10, 2014 · 2 comments

Comments

@object
Copy link
Contributor

object commented Mar 10, 2014

This one is marked in the source code as "TODO" item, however I would like to emphasize its importance. Right now if I serialize and object into a JSON string and send it to JsonLdProcessor.Expand, it will mistakenly interpret it as a URI and of course fail. This is due to very weak check if in the code:

(input.Type == JTokenType.String && ((string)input).Contains(":"))

If it's a URI string that is expected would it be sufficient to match a regex here?

@lanthaler
Copy link

Yeah, that’s true. In my implementation I check the first non-whitespace character. If it is a “[“ or “{“, you’ll now that it is a JSON array or object (those are the only two supported top-level structures); if not, it is a URL (or an error).

@emgarten
Copy link
Contributor

@object thanks for the PR for this! It has been merged into 1.0.5

5bdd4e8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants