Regular expression for SRC attribute is wrong
sinasquax - August 12, 2009 - 17:02
| Project: | Pathologic |
| Version: | 6.x-2.0-beta20 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
Hello, i have installed pathologic on my website and all is ok until i have installed the new version, links are bad.
It's because the path is no more absolute and prefix language is added to the path and images are not found.

#1
sinasquax:
If you need to downgrade, you can download the previous Beta release (Beta 19) here.
But before you do that, could you give me a bit more info? Some examples of paths that you are entering and what they're turning into would be helpful.
#2
Thank you, i have this link in content :
"sites/default/files/home_0.jpg"
And in output i have the same link (in the source code of output page) :
"sites/default/files/home_0.jpg"
So the browser adds the prefix path and i get : "http://localhost/test/fr/sites/default/files/home_0.jpg"
The language prefix causes the problem.
With the older version, i had the same link in content and it turned into absolute path : "http://localhost/test/sites/default/files/home_0.jpg" (in the source code of output page)
Thank you
#3
Hmm. This path is in a link tag (<a>) and not an image tag (<img>), right?
I'm not sure why that would be happening all of a sudden…
#4
I just did some testing by setting up a multilingual site myself, but I couldn't replicate the problem. The only thing I could see which might cause this to happen is if "sites/default/files/home_0.jpg" were in Drupal's "url_alias" database table as a legit internal Drupal path, but that should be unlikely. Hmm.
#5
Paths are in img tag, paths in link tag works normally.
Paths are not in url_alias table, i will try to find why this bug happens.
Thank you
#6
If you want reproduce the bug, you must set "Language Negotiation" because the problem happens when you set "Language Negotiation" to "Path prefix only" or "Path prefix with language fallback" (in admin/settings/language/configure)
#7
sinasquax, do you know how to apply patches? If so, could you try applying the attached patch and let me know if it works?
If you can't do patches, please open up the pathologic.module file and change line 34 to this:
$text = preg_replace_callback('|src="(internal:)?([^/][^:"\?&]+)([\?&]([^#]+))?"|', '_pathologic_do_src', $text);Note that you'll have to edit a node and change its text before Drupal will run it through its filters again.
I think that might fix it.
#8
Great, that works !!
Thank you very much for the fix and for your excellent module
#9
Excellent! Thanks for your help. I'll release a fixed version soon.
#10
Automatically closed -- issue fixed for 2 weeks with no activity.