Skip to content
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

Stopping normalization of invalid html literals #2483

Merged

Conversation

WhiteGobo
Copy link
Contributor

Summary of changes

literal stops normalization process if html5lib cant parse literal
Tests now check, that invalid html literals wont be normalized

Fixes #2475

Checklist

  • Checked that there aren't other open pull requests for
    the same change.
  • Checked that all tests and type checking passes.
  • If the change has a potential impact on users of this project:
    • Added or updated tests that fail without the change.
    • Updated relevant documentation to avoid inaccuracies.
    • Considered adding additional documentation.
  • Considered granting push permissions to the PR branch,
    so maintainers can fix minor issues and keep your PR up to date.

WhiteGobo added 2 commits July 11, 2023 07:38
Tests now check, that invalid html literals wont be normalized
@coveralls
Copy link

coveralls commented Jul 11, 2023

Coverage Status

coverage: 90.926% (+0.02%) from 90.904% when pulling 29691f2 on WhiteGobo:stop_normalization_for_invalid_htmlliterals into e94c252 on RDFLib:main.

Copy link
Member

@aucampia aucampia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this, it is indeed the right thing to do, however running the HTML5Lib parser in strict mode may be slightly better as that results in an exception with some more information about the error. We could technically recover the same information and add it in a custom exception, but errors is an array of errors and could indicate multiple errors.

rdflib/term.py Outdated Show resolved Hide resolved
@WhiteGobo
Copy link
Contributor Author

Thank you for reviewing the code. Ive missed that option. Sounds good.

Co-authored-by: Iwan Aucamp <aucampia@gmail.com>
@aucampia
Copy link
Member

pre-commit.ci autofix

@aucampia
Copy link
Member

I'm going to merge this. I think there is still more wrong with the rdf:HTML stuff, but this should go in anyway.

@aucampia aucampia merged commit 53aaf02 into RDFLib:main Jul 12, 2023
22 checks passed
@WhiteGobo WhiteGobo deleted the stop_normalization_for_invalid_htmlliterals branch September 24, 2023 19:52
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

Successfully merging this pull request may close these issues.

Casting literal with content to rdf:HTML datatype leads incorrectly to empty literal
3 participants