raintpl3
raintpl3 copied to clipboard
Path Replace plugin don't correct work with url started from //
< img src="//google.com/1.png"> < link src="//bootstrap.com/style.css">
a path that starts with // is a wrong path
http://www.ietf.org/rfc/rfc3986.txt See Section 4.2 and Section 5.4.
"g:h" = "g:h" "g" = "http://a/b/c/g" "./g" = "http://a/b/c/g" "g/" = "http://a/b/c/g/" "/g" = "http://a/g" "//g" = "http://g" "?y" = "http://a/b/c/d;p?y" "g?y" = "http://a/b/c/g?y" "#s" = "http://a/b/c/d;p?q#s" "g#s" = "http://a/b/c/g#s" "g?y#s" = "http://a/b/c/g?y#s" ";x" = "http://a/b/c/;x" "g;x" = "http://a/b/c/g;x" "g;x?y#s" = "http://a/b/c/g;x?y#s" "" = "http://a/b/c/d;p?q" "." = "http://a/b/c/" "./" = "http://a/b/c/" ".." = "http://a/b/" "../" = "http://a/b/" "../g" = "http://a/b/g" "../.." = "http://a/" "../../" = "http://a/" "../../g" = "http://a/g"
URL starting from // is basicly protocol relative.
http://www.paulirish.com/2010/the-protocol-relative-url/
@xPaw have right there eg. Google is sharing protocol relative urls to their Google Maps api
Interesting. So means that we'll have to fix the path replace to make it compatible with the rfc 3986! Thanks for pointing this out.
Please disable the processing of URLs in A tags starting with "#" or "?", Path Replace appends to them in the beginning is always base_url and it is not good
@rainphp there is a good implementation of jQuery in PHP, its called phpQuery. Maybe it will be a better way to use this library to easiest parse HTML code and replace only text in selected tags?