Index: pathologic.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/pathologic/pathologic.module,v retrieving revision 1.7.2.9.2.2 diff -u -F '^f' -r1.7.2.9.2.2 pathologic.module --- pathologic.module 20 Apr 2010 20:12:21 -0000 1.7.2.9.2.2 +++ pathologic.module 21 Apr 2010 14:55:33 -0000 @@ -55,6 +55,29 @@ function pathologic_filter($op, $delta = } /** + * Implementation of hook_file_url_alter(). + */ +function pathologic_file_url_alter(&$path) { + // Retrieve matching paths settings. + $paths = array(); + $directive = trim(variable_get("filter_pathologic_abs_paths_1", '')); // Using Filtered HTML format. + if ($directive !== '') { + $paths = array_map('trim', explode("\n", $directive)); // Get rid of white space on each line. + } + $paths[] = _pathologic_url(''); + $paths = array_unique($paths); + + // Build regexp, match twice (with or without leading slash) and then trim + // slashes. + $path_suffix = '/?(index.php)?(\?q=)?'; // The optional suffix to match. + $path_regexp = '(' . implode($path_suffix . '|', $paths) . $path_suffix . ')'; + $original_path = $path; + $path = preg_replace($path_regexp, '', $path); + $path = preg_replace($path_regexp, '', '/' . $path); + $path = '/' . trim($path, '\\/'); +} + +/** * Pathologic filter callback. */ function _pathologic($text, $format) {