1
0
Fork 0
mirror of https://github.com/gocsaf/csaf.git synced 2025-12-22 05:40:11 +01:00

Fix url handling
Some checks failed
Go / build (push) Has been cancelled
Go / run_modver (push) Has been cancelled

Check if relative URL is absolute.
This commit is contained in:
koplas 2025-07-17 12:04:04 +01:00
parent ae184eb189
commit 164d995aaf
No known key found for this signature in database
2 changed files with 7 additions and 2 deletions

View file

@ -636,6 +636,7 @@ func (p *processor) integrity(
if err != nil { if err != nil {
return err return err
} }
b.Path = ""
client := p.httpClient() client := p.httpClient()
var data bytes.Buffer var data bytes.Buffer
@ -953,7 +954,7 @@ func (p *processor) checkIndex(base string, mask whereType) error {
continue continue
} }
files = append(files, csaf.DirectoryAdvisoryFile{Path: u}) files = append(files, csaf.DirectoryAdvisoryFile{Path: bu.JoinPath(u).String()})
} }
return files, scanner.Err() return files, scanner.Err()
}() }()
@ -1036,7 +1037,7 @@ func (p *processor) checkChanges(base string, mask whereType) error {
path := r[pathColumn] path := r[pathColumn]
times, files = append(times, t), times, files = append(times, t),
append(files, csaf.DirectoryAdvisoryFile{Path: path}) append(files, csaf.DirectoryAdvisoryFile{Path: bu.JoinPath(path).String()})
p.timesChanges[path] = t p.timesChanges[path] = t
} }
return times, files, nil return times, files, nil

View file

@ -12,6 +12,10 @@ import "net/url"
// JoinURL joins the two URLs while preserving the query and fragment part of the latter. // JoinURL joins the two URLs while preserving the query and fragment part of the latter.
func JoinURL(baseURL *url.URL, relativeURL *url.URL) *url.URL { func JoinURL(baseURL *url.URL, relativeURL *url.URL) *url.URL {
// Check if we already have an absolute url
if relativeURL.Host != "" && relativeURL.Host != baseURL.Host && relativeURL.Scheme == "https" {
return relativeURL
}
u := baseURL.JoinPath(relativeURL.Path) u := baseURL.JoinPath(relativeURL.Path)
u.RawQuery = relativeURL.RawQuery u.RawQuery = relativeURL.RawQuery
u.RawFragment = relativeURL.RawFragment u.RawFragment = relativeURL.RawFragment