1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-15 10:02:02 +02:00

Fix for broken social-share icons when JS/CSS cache was enabled.

This commit is contained in:
Cameron 2016-03-11 19:40:59 -08:00
parent f8ed7ac1d4
commit e9869319f3
3 changed files with 56 additions and 2 deletions

View File

@ -1523,7 +1523,7 @@ class e_jsmanager
$path = str_replace("../",'',$path);
$basePath = SITEURL.dirname($path)."/";
$basePath = dirname($path)."/";
foreach($match[1] as $k=>$v)
{
@ -1533,7 +1533,11 @@ class e_jsmanager
continue;
}
$dir = "url(".$basePath.$v.")"; // relative to e_WEB_ABS."cache/";
$path = $this->normalizePath($basePath.$v);
$dir = "url(".SITEURL.$path.")"; // relative to e_WEB_ABS."cache/";
// print_a($dir);
$newpath[$k] = $dir;
}
@ -1543,6 +1547,54 @@ class e_jsmanager
}
/**
* Normalize a path.
* Replacement for realpath (move to core functions?)
* It will _only_ normalize the path and resolve indirections (.. and .)
* Normalization includes:
* - directiory separator is always /
* - there is never a trailing directory separator
* @param $path
* @return String
*/
private function normalizePath($path)
{
$parts = preg_split(":[\\\/]:", $path); // split on known directory separators
// resolve relative paths
for ($i = 0; $i < count($parts); $i +=1)
{
if ($parts[$i] === "..") // resolve ..
{
if ($i === 0)
{
throw new Exception("Cannot resolve path, path seems invalid: `" . $path . "`");
}
unset($parts[$i - 1]);
unset($parts[$i]);
$parts = array_values($parts);
$i -= 2;
}
elseif ($parts[$i] === ".") // resolve .
{
unset($parts[$i]);
$parts = array_values($parts);
$i -= 1;
}
if ($i > 0 && $parts[$i] === "") // remove empty parts
{
unset($parts[$i]);
$parts = array_values($parts);
}
}
return implode("/", $parts);
}
/**
* Minify JS/CSS for output
* @param string $minify

View File

@ -10,6 +10,7 @@
<media_dimensions>false</media_dimensions>
<media_poster>false</media_poster>
<media_filter_html>false</media_filter_html>
<plugin_preview_width>800</plugin_preview_width>
<extended_valid_elements>i[*], object[*],embed[*],bbcode[*]</extended_valid_elements>
<templates>[
{

View File

@ -6,6 +6,7 @@
<toolbar1>undo redo | removeformat | styleselect | bold italic underline forecolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image template | smileys | preview</toolbar1>
<external_plugins>e107 compat3x</external_plugins>
<image_advtab>false</image_advtab>
<plugin_preview_width>800</plugin_preview_width>
<extended_valid_elements>i[*], bbcode[*]</extended_valid_elements>
<templates>[
{