Source File
safehtmlutil.go
Belonging Package
github.com/google/safehtml/internal/safehtmlutil
package safehtmlutil
import (
)
func ( string) bool {
return safeTrustedResourceURLPrefixPattern.MatchString()
}
var safeTrustedResourceURLPrefixPattern = regexp.MustCompile(`(?i)^(?:` +
`(?:https:)?//[0-9a-z.:\[\]-]+/|` +
`/[^/\\]|` +
`about:blank#)`)
func ( string) bool {
return urlDoubleDotSegmentPattern.MatchString()
}
var urlDoubleDotSegmentPattern = regexp.MustCompile(`(?i)(?:\.|%2e)(?:\.|%2e)`)
func ( ...interface{}) string {
return urlProcessor(false, Stringify(...))
}
func ( ...interface{}) string {
return urlProcessor(true, Stringify(...))
}
for , := 0, len(); < ; ++ {
:= []
case '!', '#', '$', '&', '*', '+', ',', '/', ':', ';', '=', '?', '@', '[', ']':
if {
continue
case '-', '.', '_', '~':
continue
if 'a' <= && <= 'z' {
continue
}
if 'A' <= && <= 'Z' {
continue
}
if '0' <= && <= '9' {
continue
}
}
.WriteString([:])
fmt.Fprintf(&, "%%%02x", )
= + 1
}
if == 0 {
return
}
.WriteString([:])
return .String()
}
![]() |
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. |