Source File
url.go
Belonging Package
github.com/google/safehtml/template
package template
import (
)
var startsWithFullySpecifiedSchemePattern = regexp.MustCompile(
`^[[:alpha:]](?:[[:alnum:]]|[+-.])*:`)
func ( string) error {
, := decodeURLPrefix()
if != nil {
return
}
switch {
case startsWithFullySpecifiedSchemePattern.MatchString():
if safehtml.URLSanitized().String() != {
return fmt.Errorf("URL prefix %q contains an unsafe scheme", )
}
func ( string) error {
, := decodeURLPrefix()
if != nil {
return
}
if !safehtmlutil.IsSafeTrustedResourceURLPrefix() {
return fmt.Errorf("%q is a disallowed TrustedResourceURL prefix", )
}
return nil
}
var endsWithPercentEncodingPrefixPattern = regexp.MustCompile(
`%[[:xdigit:]]?$`)
var containsWhitespaceOrControlPattern = regexp.MustCompile(`[[:space:]]|[[:cntrl:]]`)
func ( string) (string, error) {
if containsWhitespaceOrControlPattern.MatchString() {
return "", fmt.Errorf("URL prefix %q contains whitespace or control characters", )
}
if := validateDoesNotEndsWithCharRefPrefix(); != nil {
return "", fmt.Errorf("URL %s", )
}
if containsWhitespaceOrControlPattern.MatchString() {
return "", fmt.Errorf("URL prefix %q contains whitespace or control characters", )
}
if endsWithPercentEncodingPrefixPattern.MatchString() {
return "", fmt.Errorf("URL prefix %q ends with an incomplete percent-encoding character triplet", )
}
return , nil
}
func ( ...interface{}) (string, error) {
:= safehtmlutil.Stringify(...)
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |