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

Remove unsafe { … } code from askama_escape #665

Merged
merged 1 commit into from
Apr 13, 2022
Merged

Remove unsafe { … } code from askama_escape #665

merged 1 commit into from
Apr 13, 2022

Conversation

Kijewski
Copy link
Collaborator

Using only safe code is actually same as fast as the previous "unsafe"
code according to the crate's benchmark.

The code was extracted from markup's escape function in escape.rs,
written by Utkarsh Kukreti [email protected], licensed as
MIT OR Apache-2.0.

Using only safe code is actually same as fast as the previous "unsafe"
code according to the crate's benchmark.

The code was extracted from [markup]'s escape function in [escape.rs],
written by Utkarsh Kukreti <[email protected]>, licensed as
`MIT OR Apache-2.0`.

[markup]: https://crates.io/crates/markup
[escape.rs]: https://github.com/utkarshkukreti/markup.rs/blob/8ec40428483790b2c296e907e7be4147b157fe8f/markup/src/escape.rs#L1-L21
Copy link
Collaborator

@djc djc left a comment

Choose a reason for hiding this comment

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

Nice!

@Kijewski
Copy link
Collaborator Author

This is the only remaining unsafe line in the whole project AFAICT:
https://github.com/djc/askama/blob/d4c674064e0e95bbc68c99f7e458d0128020ac7f/askama_escape/src/lib.rs#L176

What do you think, should I replace it with its safe variant, too? I don't think that anyone will put tons of JSON in their output, so the difference might be neglectable.

@djc djc merged commit fc779e2 into rinja-rs:main Apr 13, 2022
@djc
Copy link
Collaborator

djc commented Apr 13, 2022

I'm honestly not too bothered about having some unsafe code, as long as the invariant is clearly upheld.

@Kijewski Kijewski deleted the pr-safe-escape branch April 13, 2022 11:19
@djc djc mentioned this pull request Feb 26, 2023
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.

2 participants