I am working on a site where (really bad) users embedded lots of images with bad URLs including spaces and special characters at the start
Something like
<img src="
http://mySite.com/path/to/myImage.jpg">
Because of the way Pathologic find the paths to replace, the ouput is
<img src="http://mysite.com/%20%26#9; http://myothersite.com/path/to/myImage.jpg">
and obviously the image is not loaded on the final page (although it is loaded in ckEditor!)
It comes from the pattern used to detect which URLs should be parsed
return preg_replace_callback('~ (href|src|action|longdesc)="([^"]+)~i', '_pathologic_replace', $text);
it suppose that what comes right after the opening " is the URL to be treated
I replaced it with
return preg_replace_callback('~ (href|src|action|longdesc)="[^a-zA-Z/#?&=]*([^"]+)~i', '_pathologic_replace', $text);
so that it consider that the url is anything after the opening " which starts with a letter or a /
I am sure there are cases for which it is not correct, but it works for me, I thought I would report the issue so that you can add this kind of URLs to your tests and maybe find a better solution than me
Thanks a lot for this module, it really is a great help!
Comments
Comment #2
pillona commentedComment #3
pillona commented