mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 11:55:40 +01:00
Trimmed redirects (#230)
* Changes phrasing of redirects to be clearer. Now omits redirects if they are already listed as part of a larger redirect chain * Rebuilt how the redirection string is built. Now checks for duplicate redirections after all redirections have been read * Fixes intendation error * Fixed redirect output. * Fixed recording redirects. Co-authored-by: Jan Höfelmeyer <Jan Höfelmeyer jhoefelmeyer@intevation.de> Co-authored-by: Sascha L. Teichmann <sascha.teichmann@intevation.de>
This commit is contained in:
parent
56a047cdde
commit
c00b8b37bb
2 changed files with 40 additions and 17 deletions
|
|
@ -43,7 +43,7 @@ type processor struct {
|
|||
opts *options
|
||||
client util.Client
|
||||
|
||||
redirects map[string]string
|
||||
redirects map[string][]string
|
||||
noneTLS map[string]struct{}
|
||||
alreadyChecked map[string]whereType
|
||||
pmdURL string
|
||||
|
|
@ -259,19 +259,19 @@ func (p *processor) markChecked(s string, mask whereType) bool {
|
|||
|
||||
func (p *processor) checkRedirect(r *http.Request, via []*http.Request) error {
|
||||
|
||||
var path strings.Builder
|
||||
for i, v := range via {
|
||||
if i > 0 {
|
||||
path.WriteString(", ")
|
||||
}
|
||||
path.WriteString(v.URL.String())
|
||||
}
|
||||
url := r.URL.String()
|
||||
p.checkTLS(url)
|
||||
if p.redirects == nil {
|
||||
p.redirects = map[string]string{}
|
||||
p.redirects = map[string][]string{}
|
||||
}
|
||||
|
||||
if redirects := p.redirects[url]; len(redirects) == 0 {
|
||||
redirects = make([]string, len(via))
|
||||
for i, v := range via {
|
||||
redirects[i] = v.URL.String()
|
||||
}
|
||||
p.redirects[url] = redirects
|
||||
}
|
||||
p.redirects[url] = path.String()
|
||||
|
||||
if len(via) > 10 {
|
||||
return errors.New("too many redirections")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue