[enh] use href attribute of base tag for base URL if presented
closes #18 git-svn-id: file:///srv/svn/repo/yukari/trunk@38 f3bd38d9-da89-464d-a02a-eb04e43141b5
This commit is contained in:
parent
7cd3fb67cd
commit
e65b8cfd9e
16
morty.go
16
morty.go
@ -347,6 +347,22 @@ func sanitizeHTML(rc *RequestConfig, out io.Writer, htmlDoc []byte) {
|
||||
}
|
||||
break
|
||||
}
|
||||
if bytes.Equal(tag, []byte("base")) {
|
||||
for {
|
||||
attrName, attrValue, moreAttr := decoder.TagAttr()
|
||||
if !bytes.Equal(attrName, []byte("href")) {
|
||||
continue
|
||||
}
|
||||
parsedURI, err := url.Parse(string(attrValue))
|
||||
if err == nil {
|
||||
rc.BaseURL = parsedURI
|
||||
}
|
||||
if !moreAttr {
|
||||
break
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
if bytes.Equal(tag, []byte("noscript")) {
|
||||
state = STATE_IN_NOSCRIPT
|
||||
break
|
||||
|
Loading…
x
Reference in New Issue
Block a user