Skip to content

Update urlchar to handle character escaping.#9

Merged
kisielk merged 2 commits intogorilla:masterfrom
daohoangson:fix_chars_need_escaping
Jan 15, 2017
Merged

Update urlchar to handle character escaping.#9
kisielk merged 2 commits intogorilla:masterfrom
daohoangson:fix_chars_need_escaping

Conversation

@daohoangson
Copy link
Copy Markdown
Contributor

@daohoangson daohoangson commented Jan 15, 2017

Basic idea: urlchar should accept [(ascii characters minus those that need escaping)(non ascii characters)(escaped sequences)]. The 2 later parts are taken care of by {nonascii} and {escape} macro already. Below is the broken down explanation for the first part:

ASCII characters range = [\u0020-\u007e]
Skip space \u0020 = [\u0021-\u007e]
Skip quotation mark \0022 = [\u0021\u0023-\u007e]
Skip apostrophe \u0027 = [\u0021\u0023-\u0026\u0028-\u007e]
Skip reverse solidus \u005c = [\u0021\u0023-\u0026\u0028-\u005b\u005d\u007e]
Also, the left square bracket (\u005b) and right (\u005d) needs escaping themselves, hence the final regex

Basic idea: urlchar should accept [(ascii characters minus those that need escaping)(non ascii characters)(escaped sequences)]. The 2 later parts are taken cared of by {nonascii} and {escape} macro already. Below is the broken down explanation for the first part:

ASCII characters range = [\u0020-\u007e]
Skip space \u0020 = [\u0021-\u007e]
Skip quotation mark \0022 = [\u0021\u0023-\u007e]
Skip apostrophe \u0027 = [\u0021\u0023-\u0026\u0028-\u007e]
Skip reverse solidus \u005c = [\u0021\u0023-\u0026\u0028-\u005b\u005d\u007e]
Also, the left square bracket (\u005b) and right (\u005d) needs escaping themselves, hence the final regex
@kisielk
Copy link
Copy Markdown
Contributor

kisielk commented Jan 15, 2017

That seems reasonable to me. Can you include a description of the characters as you have done in this PR in the comments in the code? That will give people looking at it in the future some point of reference.

@daohoangson
Copy link
Copy Markdown
Contributor Author

@kisielk sure thing.

@kisielk kisielk merged commit 67c8b4b into gorilla:master Jan 15, 2017
@kisielk
Copy link
Copy Markdown
Contributor

kisielk commented Jan 15, 2017

Cool. Thanks a lot! 👍

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