Changeset 36 in code for trunk/morty.go
- Timestamp:
- Nov 24, 2016, 9:30:15 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/morty.go
r35 r36 110 110 <div id="mortyheader"> 111 111 <input type="checkbox" id="mortytoggle" autocomplete="off" /> 112 <div><p>This is a proxified and sanitized view of the page,<br />visit <a href="%s" >original site</a>.</p><div><p><label for="mortytoggle">hide</label></p></div></div>112 <div><p>This is a proxified and sanitized view of the page,<br />visit <a href="%s" rel="noreferrer">original site</a>.</p><p><label for="mortytoggle">hide</label></p></div> 113 113 </div> 114 114 <style> 115 #mortyheader { position: fixed; top: 15%%; left: 0; max-width: 10em; color: #444; overflow: hidden; z-index: 110000; font-size: 0.9em; padding: 1em 1em 1em 0; margin: 0; }116 #mortyheader a { color: #3498db; }117 #mortyheader p { padding: 0 ; margin: 0; }118 #mortyheader > div { padding: 8px; font-size: 0.9em; border-width: 4px 4px 4px 0; border-style: solid; border-color: #1abc9c; background: #FFF; line-height: 1em; }115 #mortyheader { position: fixed; padding: 12px 12px 12px 0; margin: 0; box-sizing: content-box; top: 15%%; left: 0; max-width: 140px; color: #444; overflow: hidden; z-index: 110000; font-size: 12px; line-height: normal; } 116 #mortyheader a { color: #3498db; font-weight: bold; } 117 #mortyheader p { padding: 0 0 0.7em 0; margin: 0; } 118 #mortyheader > div { padding: 8px; font-size: 12px !important; font-family: sans !important; border-width: 4px 4px 4px 0; border-style: solid; border-color: #1abc9c; background: #FFF; line-height: 1em; } 119 119 #mortyheader label { text-align: right; cursor: pointer; display: block; color: #444; padding: 0; margin: 0; } 120 120 input[type=checkbox]#mortytoggle { display: none; } … … 307 307 startIndex = urlEnd 308 308 } else { 309 log.Println("cannot proxify css uri:", css[urlStart:urlEnd])309 log.Println("cannot proxify css uri:", string(css[urlStart:urlEnd])) 310 310 } 311 311 } … … 504 504 if bytes.Equal(http_equiv, []byte("refresh")) && urlIndex != -1 { 505 505 contentUrl := content[urlIndex+4:] 506 // special case of <meta http-equiv="refresh" content="0; url='example.com/url.with.quote.outside'"> 507 if len(contentUrl)>=2 && (contentUrl[0] == byte('\'') || contentUrl[0] == byte('"')) { 508 if contentUrl[0] == contentUrl[len(contentUrl)-1] { 509 contentUrl=contentUrl[1:len(contentUrl)-1] 510 } 511 } 512 // output proxify result 506 513 if uri, err := rc.ProxifyURI(string(contentUrl)); err == nil { 507 514 fmt.Fprintf(out, ` http-equiv="refresh" content="%surl=%s"`, content[:urlIndex], uri) … … 529 536 fmt.Fprintf(out, " %s=\"%s\"", attrName, uri) 530 537 } else { 531 log.Println("cannot proxify uri:", attrValue)538 log.Println("cannot proxify uri:", string(attrValue)) 532 539 } 533 540 case "style": … … 538 545 } 539 546 540 func mergeURIs(u1, u2 *url.URL) (*url.URL){547 func mergeURIs(u1, u2 *url.URL) *url.URL { 541 548 return u1.ResolveReference(u2) 542 549 } … … 603 610 <head> 604 611 <title>MortyProxy</title> 612 <meta name="viewport" content="width=device-width, initial-scale=1 , maximum-scale=1.0, user-scalable=1" /> 605 613 <style> 606 body { font-family: 'Garamond', 'Georgia', serif; text-align: center; color: #444; background: #FAFAFA; margin: 0; padding: 0; font-size: 1.1em; } 614 html { height: 100%; } 615 body { min-height : 100%; display: flex; flex-direction:column; font-family: 'Garamond', 'Georgia', serif; text-align: center; color: #444; background: #FAFAFA; margin: 0; padding: 0; font-size: 1.1em; } 607 616 input { border: 1px solid #888; padding: 0.3em; color: #444; background: #FFF; font-size: 1.1em; } 617 input[placeholder] { width:80%; } 608 618 a { text-decoration: none; #2980b9; } 609 619 h1, h2 { font-weight: 200; margin-bottom: 2rem; } 610 620 h1 { font-size: 3em; } 611 .footer { position: absolute; bottom: 2em; width: 100%; } 621 .container { flex:1; min-height: 100%; margin-bottom: 1em; } 622 .footer { margin: 1em; } 612 623 .footer p { font-size: 0.8em; } 613 614 624 </style> 615 625 </head> 616 626 <body> 617 <h1>MortyProxy</h1>`)) 627 <div class="container"> 628 <h1>MortyProxy</h1> 629 `)) 618 630 if err != nil { 619 631 log.Println("error:", err) … … 624 636 if p.Key == nil { 625 637 ctx.Write([]byte(` 626 <form action="post">627 Visit url: <input placeholder="https://url.." name="mortyurl"/>628 <input type="submit" value="go" />629 </form>`))638 <form action="post"> 639 Visit url: <input placeholder="https://url.." name="mortyurl" autofocus /> 640 <input type="submit" value="go" /> 641 </form>`)) 630 642 } else { 631 643 ctx.Write([]byte(`<h3>Warning! This instance does not support direct URL opening.</h3>`)) 632 644 } 633 645 ctx.Write([]byte(` 634 <div class="footer"> 635 <p>Morty rewrites web pages to exclude malicious HTML tags and CSS/HTML attributes. It also replaces external resource references to prevent third-party information leaks.<br /> 636 <a href="https://github.com/asciimoo/morty">view on github</a> 637 </p> 638 </div> 646 </div> 647 <div class="footer"> 648 <p>Morty rewrites web pages to exclude malicious HTML tags and CSS/HTML attributes. It also replaces external resource references to prevent third-party information leaks.<br /> 649 <a href="https://github.com/asciimoo/morty">view on github</a> 650 </p> 651 </div> 639 652 </body> 640 653 </html>`))
Note:
See TracChangeset
for help on using the changeset viewer.