Refuse an image URL whose source path or query holds a # (closes #286)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
A # written as %23 in the source path or query reached the parser decoded and stayed in the source URL, where Go reads it as the start of a fragment and drops it before fetching. So each text after the # was another unsigned spelling of one upstream request, cached under its own keys. An image URL whose decoded source path or query holds a # is now refused with 400, signed or not, and README.md's rule for writing a source path and query says a # cannot be part of either. Model: opus-5-5
This commit was merged in pull request #287.
This commit is contained in:
@@ -171,6 +171,14 @@ func parseImageComponents(remainder string) (*ParsedURL, error) {
|
||||
// host
|
||||
host = strings.ToLower(host)
|
||||
|
||||
// Go's URL parser, which the fetcher uses, reads a "#" as the start of a
|
||||
// fragment and drops the rest, so each text after it would be another
|
||||
// spelling, cached under its own keys, of one upstream request
|
||||
if strings.Contains(path, "#") {
|
||||
return nil, fmt.Errorf(
|
||||
`%w: the source path or query holds a "#"`, ErrInvalidPath)
|
||||
}
|
||||
|
||||
// Extract query string if present in path
|
||||
if qIndex := strings.Index(path, "?"); qIndex != -1 {
|
||||
query = path[qIndex+1:]
|
||||
|
||||
Reference in New Issue
Block a user