diff -r ad5684b57ab7 web/sites/all/modules/pathologic/pathologic.module --- a/web/sites/all/modules/pathologic/pathologic.module Thu Sep 08 08:08:28 2011 +0000 +++ b/web/sites/all/modules/pathologic/pathologic.module Thu Sep 08 10:23:45 2011 +0200 @@ -114,6 +114,8 @@ * Replace the attributes. preg_replace_callback() callback. */ function _pathologic_replace($matches, $absolute) { + global $language; + // First, "files:" support. This is fairly easy. if ($matches[2] === 'files:') { return $matches[1] . '="' . file_create_url(file_build_uri(urldecode($matches[3]))) . '"'; @@ -150,17 +152,24 @@ $qparts = NULL; } - $url = url( - $parts['path'], - array( - 'query' => $qparts, - 'fragment' => isset($parts['fragment']) ? $parts['fragment'] : NULL, - 'absolute' => $absolute, - ) + // Build common url() options. + $url_options = array( + 'query' => $qparts, + 'fragment' => isset($parts['fragment']) ? $parts['fragment'] : NULL, + 'absolute' => $absolute, + // Newer versions of PHP treat all objects as references, + // so we have to clone objects we might modify. + 'language' => clone($language), ); - // $matches[1] will be the attribute; src, href, etc. - return "{$matches[1]}=\"{$url}\""; + // Check if this is not a menu item. If yes, we want to try prevent translating the path. + // On multi-lingual sites, language_url_rewrite() will be called and may + // rewrite the link in ways we don't want: drupal.org/node/961618 + if (!menu_get_item($parts['path'])) { + $url_options['language']->prefix = ''; + } + + return $matches[1] . '="' . url($parts['path'], $url_options) . '"'; } /**