I had a little issue with pathologic and wanted to create tests for this case. But even before starting to work on this I started the "Pathologic path filtering" test case to see the result. It showed 5 fails, 4 with 'Path with just slash' and one with '"Also considered local" paths'.

The modification to make the "path with just slash" was pretty simple:

if ($parts['trimmed_path'] === '') {
# become
if ($parts['trimmed_path'] === '' || $parts['trimmed_path'] === '/') {

The '"Also considered local" paths' was much harder to get pass.

# there was a typo in the test:
'local_paths' => "http://example.com/qux\nexample.org\/bananas",
#become
'local_paths' => "http://example.com/qux\nexample.org\n/bananas",

# i also added a clean_url reset before making the last tests
variable_set('clean_url', TRUE);

In the _pathologic_filter function the $parts needed to be rebuild if the expolded path was just a domain. This was especially done for the example.org path in the '"Also considered local" paths' test.

In _pathologic_replace the local_path is kept in a variable. This was needed to clean the url in cases where the local path point to a subdirectory (http://example.com/qux).

Comments

idflood’s picture

StatusFileSize
new4.1 KB
idflood’s picture

Status: Active » Needs review
StatusFileSize
new3.81 KB

Little cleanup of previous patch, removed the unnecessary 'if ($parts['trimmed_path'] === '')' modification since there is now a function that remove the starting / just before.

idflood’s picture

Here is a patch that combines the one in #2 and the second patch of #71 in #348421: Multilingual links with Pathologic.

It needs more testing but it fixes the tests and the issues I had on a website.

idflood’s picture

New patch that simplify the language handling. Combine patch from #2 with the patch in #73 from #348421: Multilingual links with Pathologic.

palamida’s picture

So far so good...
applied patch #4 and pictures are ok
going to do some more testing... (maybe something wrong with linkit... missing language prefix - but must check)

Garrett Albright’s picture

idflood, I didn't want to use the first part of your patch which tried to guess if a path actually had a host part or not - I'm worried it will introduce ambiguity - but as for the rest of the things you address, do you think you could take a look at the Beta 2 release and see how it goes for you?

idflood’s picture

Status: Needs review » Closed (fixed)

I tried today with the latest 2.x-dev version from git. It fixes all the previous tests but still fail on the new language handling test. I close this issue since the only remaining bug is specific to #348421: Multilingual links with Pathologic

idflood’s picture

Issue summary: View changes

typo