mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-23 16:58:31 +02:00
fix: limit redirect count when parsing html for favicon, fix url sanitize method
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package strutils
|
||||
|
||||
import "path"
|
||||
import (
|
||||
"path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// SanitizeURI sanitizes a URI reference to ensure it is safe
|
||||
// It disallows URLs beginning with // or /\ as absolute URLs,
|
||||
@@ -10,6 +13,9 @@ func SanitizeURI(uri string) string {
|
||||
if uri == "" {
|
||||
return "/"
|
||||
}
|
||||
if strings.HasPrefix(uri, "http://") || strings.HasPrefix(uri, "https://") {
|
||||
return uri
|
||||
}
|
||||
if uri[0] != '/' {
|
||||
uri = "/" + uri
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user