Issue 1038 fixed bugs of replacing path and target attribute in html <a> tag, when opage is compiled on page module

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@10245 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ngleader 2012-02-28 08:24:23 +00:00
parent 63ba711c99
commit cd90597c60

View file

@ -157,8 +157,7 @@
@include($path);
$content = ob_get_clean();
// Replace relative path to the absolute path
$path_info = pathinfo($path);
$this->path = str_replace('\\', '/', realpath($path_info['dirname'])).'/';
$this->path = str_replace('\\', '/', realpath(dirname($path))) . '/';
$content = preg_replace_callback('/(target=|src=|href=|url\()("|\')?([^"\'\)]+)("|\'\))?/is',array($this,'_replacePath'),$content);
$content = preg_replace_callback('/(<!--%import\()(\")([^"]+)(\")/is',array($this,'_replacePath'),$content);
@ -186,7 +185,7 @@
$val = trim($matches[3]);
// Pass if the path is external or starts with /, #, { characters
// /=absolute path, #=hash in a page, {=Template syntax
if(preg_match('@^((?:http|https|ftp|telnet|mms)://|(?:mailto|javascript):|[/#{])@i',$val)) {
if(strpos($val, '.') === FALSE || preg_match('@^((?:http|https|ftp|telnet|mms)://|(?:mailto|javascript):|[/#{])@i',$val)) {
return $matches[0];
// In case of .. , get a path
} elseif(preg_match('/^\.\./i',$val)) {