Google Safe Browsing #19
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Not necessarily a pull request but a work in progress and discussion.
I added a mode option and trying to have the code successfully perform all normalization tests mentioned on the below document when run with 'safebrowsing' mode. So far 30 out of 34 tests are successful. Rationale comes from the Canonicalization section of this document https://developers.google.com/safe-browsing/developers_guide_v2
Not sure if the mode is the correct way to go. Some of the fixes introduced are specific to Google Safe Browsing rules, such as removing the fragment part of the query. Most people will expect the url to contain the fragment after normalization, but instead of a mode this might be an option when getting back the normalized url as a whole. Also converting a non ascii host to percent-escape or punycode or leaving as it is might need to be an option.
There are also other fixes which I left out of the 'safebrowsing' mode as they did not break tests with the original code.