raintpl3 icon indicating copy to clipboard operation
raintpl3 copied to clipboard

Path Replace plugin don't correct work with url started from //

Open imonly opened this issue 11 years ago • 7 comments

< img src="//google.com/1.png"> < link src="//bootstrap.com/style.css">

imonly avatar Jul 29 '13 04:07 imonly

a path that starts with // is a wrong path

feulf avatar Jul 29 '13 04:07 feulf

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"

imonly avatar Jul 29 '13 04:07 imonly

URL starting from // is basicly protocol relative.

http://www.paulirish.com/2010/the-protocol-relative-url/

xPaw avatar Jul 29 '13 07:07 xPaw

@xPaw have right there eg. Google is sharing protocol relative urls to their Google Maps api

keskad avatar Jul 29 '13 08:07 keskad

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.

feulf avatar Jul 29 '13 22:07 feulf

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

imonly avatar Aug 14 '13 13:08 imonly

@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?

keskad avatar Aug 14 '13 13:08 keskad