- Timestamp:
- Nov 22, 2016, 9:10:52 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/morty.go
r27 r28 12 12 "log" 13 13 "net/url" 14 "path"15 14 "regexp" 16 15 "strings" … … 383 382 if bytes.Equal(attr[0], []byte("action")) { 384 383 formURL, _ = url.Parse(string(attr[1])) 385 mergeURIs(rc.BaseURL, formURL)384 formURL = mergeURIs(rc.BaseURL, formURL) 386 385 break 387 386 } … … 527 526 } 528 527 529 func mergeURIs(u1, u2 *url.URL) { 530 if u2.Scheme == "" || u2.Scheme == "//" { 531 u2.Scheme = u1.Scheme 532 } 533 if u2.Host == "" && u1.Path != "" { 534 u2.Host = u1.Host 535 if len(u2.Path) == 0 || u2.Path[0] != '/' { 536 u2.Path = path.Join(u1.Path[:strings.LastIndexByte(u1.Path, byte('/'))], u2.Path) 537 } 538 } 528 func mergeURIs(u1, u2 *url.URL) (*url.URL) { 529 return u1.ResolveReference(u2) 539 530 } 540 531 541 532 func (rc *RequestConfig) ProxifyURI(uri string) (string, error) { 533 // remove javascript protocol 534 if strings.HasPrefix(uri, "javascript:") { 535 return "", nil 536 } 542 537 // TODO check malicious data: - e.g. data:script 543 538 if strings.HasPrefix(uri, "data:") { … … 553 548 return "", err 554 549 } 555 mergeURIs(rc.BaseURL, u)550 u = mergeURIs(rc.BaseURL, u) 556 551 557 552 uri = u.String()
Note:
See TracChangeset
for help on using the changeset viewer.