Changeset 13 in code for trunk/morty.go
- Timestamp:
- Oct 27, 2016, 2:16:10 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/morty.go
r12 r13 47 47 []byte("align"), 48 48 []byte("alt"), 49 []byte("as"), 49 50 []byte("autocomplete"), 50 51 []byte("charset"), … … 329 330 } 330 331 var attrs [][][]byte 331 fmt.Fprintf(out, "<%s", tag)332 332 if hasAttrs { 333 333 for { … … 338 338 } 339 339 } 340 } 341 if bytes.Equal(tag, []byte("link")) { 342 sanitizeLinkTag(rc, out, attrs) 343 break 344 } 345 346 fmt.Fprintf(out, "<%s", tag) 347 348 if hasAttrs { 340 349 if bytes.Equal(tag, []byte("meta")) { 341 350 sanitizeMetaAttrs(rc, out, attrs) … … 344 353 } 345 354 } 355 346 356 if token == html.SelfClosingTagToken { 347 357 fmt.Fprintf(out, " />") … … 352 362 } 353 363 } 364 354 365 if bytes.Equal(tag, []byte("form")) { 355 366 var formURL *url.URL … … 421 432 } 422 433 434 func sanitizeLinkTag(rc *RequestConfig, out io.Writer, attrs [][][]byte) { 435 exclude := false 436 for _, attr := range attrs { 437 attrName := attr[0] 438 attrValue := attr[1] 439 if bytes.Equal(attrName, []byte("rel")) { 440 if bytes.Equal(attrValue, []byte("dns-prefetch")) { 441 exclude = true 442 break 443 } 444 } 445 if bytes.Equal(attrName, []byte("as")) { 446 if bytes.Equal(attrValue, []byte("script")) { 447 exclude = true 448 break 449 } 450 } 451 } 452 453 if !exclude { 454 out.Write([]byte("<link")) 455 for _, attr := range attrs { 456 sanitizeAttr(rc, out, attr[0], attr[1]) 457 } 458 out.Write([]byte(">")) 459 } 460 } 461 423 462 func sanitizeMetaAttrs(rc *RequestConfig, out io.Writer, attrs [][][]byte) { 424 463 var http_equiv []byte
Note:
See TracChangeset
for help on using the changeset viewer.