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

Refactor SandboxDirective #258

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

NiedziolkaMichal
Copy link

This is simple refactor to SandboxDirective class, shrinking its size and introducing enum "Value" containing all keywords. This change is useful to me, because I can unhardcore sandbox keywords from HTML Validator.

@NiedziolkaMichal
Copy link
Author

I have also added following public methods: setValue, isActive, getActiveValues

Comment on lines 61 to 62
if (token.startsWith("'")) {
errors.add(Policy.Severity.Error, "Unrecognized sandbox keyword " + token + " - note that sandbox keywords do not have \"'\"s", index);
Copy link
Contributor

Choose a reason for hiding this comment

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

If the error message is going to state double quote single quote shouldn't the condition also check double quote?

if (token.startsWith("'") || token.startsWith("\"")) {

Copy link
Author

Choose a reason for hiding this comment

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

Example of this error message would be:

Unrecognized sandbox keyword 'strict-dynamic' note that sandbox keywords do not have "'"s

I have left this part intact, but I think the reason of mentioning just single quote is the fact, that Content Security Policy allows them in some situations. For keywords in Source List must have single quotes, they are handled in SourceExpressionDirective.

I guess we could include " in the condition and also change message to shouldn't be surrounded with quotes. That would be ok?

Copy link
Contributor

@kingthorin kingthorin Nov 2, 2022

Choose a reason for hiding this comment

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

I was just trying to make it match ….have \"'\"s which seems to indicate either single or double. But, maybe I’m not following the pairs/escaping properly.

Copy link
Author

Choose a reason for hiding this comment

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

Alright, I have added it to PR.

@rbri
Copy link

rbri commented Nov 24, 2023

@NiedziolkaMichal because HtmlUnit needs this i'm currently thinking about a fork - do you like to support that?

@NiedziolkaMichal
Copy link
Author

@rbri I am not invested in this project anymore. You can use my changes as you please.

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.

3 participants