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

safe identifier characters should include all Unicode alphanumerics #4

Open
jba opened this issue Jul 15, 2020 · 0 comments
Open

safe identifier characters should include all Unicode alphanumerics #4

jba opened this issue Jul 15, 2020 · 0 comments

Comments

@jba
Copy link

jba commented Jul 15, 2020

The documentation for safe identifiers says "alphanumeric" characters are allowed, but the implementation supports only ASCII letters and numbers. Unless there are security issues with Unicode characters, they should be supported.

Motivation: documentation sites that want to use language identifiers as (part of) fragments for easy navigation, e.g. https://pkg.go.dev.

The change I'm suggesting would be from

var onlyAlphanumericsOrHyphenPattern = regexp.MustCompile(`^[-_a-zA-Z0-9]*$`)

(https://github.com/google/safehtml/blob/v0.0.2/identifier.go#L49)
to

var onlyAlphanumericsOrHyphenPattern = regexp.MustCompile(`^[-_\pL\pN]*$`)
gopherbot pushed a commit to golang/pkgsite that referenced this issue Jul 21, 2020
Convert almost all of the remainder of the dochtml package to use
safehtml. (There is still a case with comments that needs to be
dealt with.)

This requires using legacy conversions to generate
safehtml.Identifiers from Go symbols and dotted expressions,
since they contain characters that are not permitted in safehtml.Identifiers.

I filed google/safehtml#4 and
google/safehtml#5 to get those characters
allowed.

Change-Id: Ic1b821680a6cb5dfae445a87cd305ae02cd78493
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/242818
Reviewed-by: Julie Qiu <julie@golang.org>
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

No branches or pull requests

1 participant