From e51836c0d9483ba530c9479e342a69f87146c4f8 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Wed, 5 Jul 2017 17:32:11 +0900 Subject: [PATCH] Convert all relative src attributes, not just images --- classes/display/HTMLDisplayHandler.php | 9 +++------ .../components/image_link/image_link.class.php | 12 ++++-------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/classes/display/HTMLDisplayHandler.php b/classes/display/HTMLDisplayHandler.php index 228ea5ad1..b7d06056a 100644 --- a/classes/display/HTMLDisplayHandler.php +++ b/classes/display/HTMLDisplayHandler.php @@ -193,14 +193,11 @@ class HTMLDisplayHandler // handles a relative path generated by using the rewrite module if(Context::isAllowRewrite()) { - $url = parse_url(Context::getRequestUri()); - $real_path = $url['path']; - - $pattern = '/src=("|\'){1}(\.\/)?(files\/attach|files\/cache|files\/faceOff|files\/member_extra_info|modules|common|widgets|widgetstyle|layouts|addons)\/([^"\']+)\.(jpg|jpeg|png|gif)("|\'){1}/s'; - $output = preg_replace($pattern, 'src=$1' . $real_path . '$3/$4.$5$6', $output); + $pattern = '/src=("|\'){1}(?:\.\/)?((?:files\/(?:attach|cache|faceOff|member_extra_info|thumbnails)|addons|common|(?:m\.)?layouts|modules|widgets|widgetstyle)\/[^"\']+)("|\'){1}/s'; + $output = preg_replace($pattern, 'src=$1' . \RX_BASEURL . '$2$3', $output); $pattern = '/href=("|\'){1}(\?[^"\']+)/s'; - $output = preg_replace($pattern, 'href=$1' . $real_path . '$2', $output); + $output = preg_replace($pattern, 'href=$1' . \RX_BASEURL . '$2', $output); if(Context::get('vid')) { diff --git a/modules/editor/components/image_link/image_link.class.php b/modules/editor/components/image_link/image_link.class.php index ef9e6e8f1..c0385bd57 100644 --- a/modules/editor/components/image_link/image_link.class.php +++ b/modules/editor/components/image_link/image_link.class.php @@ -63,17 +63,13 @@ class image_link extends EditorHandler // Image containing the address to the address conversion request uri (rss output, etc. purposes) $temp_src = explode('/', $src); - if(substr($src, 0,2)=='./') + if(substr($src, 0, 2) === './') { - $src = Context::getRequestUri().substr($src, 2); + $src = \RX_BASEURL . substr($src, 2); } - else if(substr($src , 0, 1)=='/') + elseif(substr($src, 0, 1) !== '/' && strpos($temp_src[0], ':') !== false) { - $src = Rhymix\Framework\URL::getCurrentDomainURL($src); - } - else if(!strpos($temp_src[0],':') && $src) - { - $src = Context::getRequestUri().$src; + $src = \RX_BASEURL . $src; } $attr_output = array();