fix: the crawler and the Chrome guard keep to the site's port

Fetcher.Allowed and Key, the rendered comparison and the Chrome request
guard accept an address only on the site's effective port (explicit,
else 443 for https and 80 for http), so page code cannot make headless
Chrome reach other services on the site host's address and a link to
another port is not reported as a page of the site.
This commit is contained in:
Jakub Zych
2026-11-04 22:56:02 +01:00
parent cfeb3dff12
commit 3fdb44bce2
9 changed files with 138 additions and 48 deletions

View File

@@ -16,32 +16,21 @@ const (
)
// compareRendered compares a page's raw HTML with its JavaScript-rendered
// DOM (D-70, P33-55; pure): same-host links, an H1 or a substantial amount
// DOM (D-70, P33-55; pure): same-site links, an H1 or a substantial amount
// of text that appear only after JavaScript are one content_js finding
// with details.check rendered and details.what naming them. hosts are the
// site host and its www twin. An identical rendering finds nothing.
func compareRendered(raw, rendered *PageFacts, hosts []string) []Finding {
// with details.check rendered and details.what naming them. key is the
// crawl's address of a link (Fetcher.Key: "" off the site, another port
// included). An identical rendering finds nothing.
func compareRendered(raw, rendered *PageFacts, key func(*url.URL) string) []Finding {
if raw == nil || rendered == nil {
return nil
}
same := func(u *url.URL) (string, bool) {
if u == nil {
if u == nil || key == nil {
return "", false
}
host := strings.ToLower(u.Hostname())
for _, h := range hosts {
if host == h {
p := u.EscapedPath()
if p == "" {
p = "/"
}
if u.RawQuery != "" {
p += "?" + u.RawQuery
}
return p, true
}
}
return "", false
k := key(u)
return k, k != ""
}
before := map[string]bool{}
for _, l := range raw.Links {