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

Update regular expression for header flag #63

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

johnpryan
Copy link
Contributor

Follow up for #61 to allow more characters in the header value

@Alejandro-FA
Copy link

What about adding support for Content Security Policy headers as well? This type of header deviates a bit from the standard header=value syntax.

If we want to keep the flag approach, the regex could be changed as follows:

final _header_key = r'[\w-]+';
final _header_value = r'[\w-]+';
final _csp_header_value = r"(?:[\w-]+(?: [A-Za-z0-9-._~:/?#\[\]@!$&'()*+,%=]+)+(?:; )?)+";
final _delimiter = r';|$';
final _regex= RegExp('(${_header_key})=(${_header_value}|${_csp_header_value})(${_delimiter})');

However, this expression still fails to capture some types of headers (like the Reporting-Endpoints header), which are not straightforward to implement. Therefore, perhaps it would be a good idea to revisit the option of passing headers with a (JSON) file. What do you think @johnpryan?

Here you can find some regex examples with the proposed expression: https://regex101.com/r/8dE5UW/3

@johnpryan
Copy link
Contributor Author

@Alejandro-FA I think a JSON file makes more sense overall - maybe that's a better long-term solution than making patches to the regex.

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