Changeset 14 in code for trunk


Ignore:
Timestamp:
Oct 27, 2016, 2:47:30 PM (9 years ago)
Author:
asciimoo
Message:

[fix] case insensitive http-equiv refresh redirect handling - fixes #5

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/morty.go

    r13 r14  
    475475        }
    476476
    477         if bytes.Equal(http_equiv, []byte("refresh")) && bytes.Index(content, []byte(";url=")) != -1 {
    478                 parts := bytes.SplitN(content, []byte(";url="), 2)
    479                 if uri, err := proxifyURI(rc, string(parts[1])); err == nil {
    480                         fmt.Fprintf(out, ` http-equiv="refresh" content="%s;%s"`, parts[0], uri)
     477        urlIndex := bytes.Index(bytes.ToLower(content), []byte("url="))
     478        if bytes.Equal(http_equiv, []byte("refresh")) && urlIndex != -1 {
     479                contentUrl := content[urlIndex+4:]
     480                if uri, err := proxifyURI(rc, string(contentUrl)); err == nil {
     481                        fmt.Fprintf(out, ` http-equiv="refresh" content="%surl=%s"`, content[:urlIndex], uri)
    481482                }
    482483        } else {
Note: See TracChangeset for help on using the changeset viewer.