examples: add idna-add-post-recheck - #186
Open
astrogilda wants to merge 1 commit into
Open
Conversation
Add an IP-literal recheck after a UTS-46 mapping ToASCII call. UTS-46 NFKC mapping can fold some Unicode digits to ASCII. A host that is not an IP literal before mapping can become one after. This patch rechecks the mapped output with netip.ParseAddr and returns an error if it parses as an IP. Signed-off-by: Sankalp Gilda <sankalp.gilda@gmail.com>
Author
|
Open since 25 June with the CLA green, no reviewer requested and no comment. Before I spend more on it: does this project accept contributed examples at all? If not, say so and I will close it. The example rewrites a call site to add the post-IDNA IP-literal recheck. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add an examples/ patch that rechecks the output of a UTS-46 mapping idna.*.ToASCII call for an IP literal.
UTS-46 NFKC mapping folds some Unicode digits to their ASCII equivalents. A host that does not parse as an IP literal before mapping can parse as one after, bypassing pre-mapping checks. The patch inserts:
TrimRight handles multiple trailing dots. The trim applies only to the ParseAddr argument, leaving the ToASCII result unchanged.
This is the gopatch equivalent of Semgrep rule semgrep/semgrep-rules#3841 and CodeQL query github/codeql#21784.
Notes:
out, err := ...ToASCII(...)assignment form. Directreturn ...ToASCII(x)is not matched.(string, error)return signature.I will sign the CLA.