aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-02-19 16:50:41 -0800
committerzotlabs <mike@macgirvin.com>2017-02-19 16:50:41 -0800
commit573846707ceade4d00a4dfe3184d9f8004a3112b (patch)
tree501d9508c22be518894cb18dfec13416412073cb /include
parent02e487f30687a1602bd257e2acf2b9954aab6e98 (diff)
downloadvolse-hubzilla-573846707ceade4d00a4dfe3184d9f8004a3112b.tar.gz
volse-hubzilla-573846707ceade4d00a4dfe3184d9f8004a3112b.tar.bz2
volse-hubzilla-573846707ceade4d00a4dfe3184d9f8004a3112b.zip
fix several places where head_add_(css|js) functions have been used incorrectly. It appears that mistakes were made going back a long time and propagated. Here's the way it should work:
- if there is no preceding / character, we look for the file within all the appropriate theme directories. - otherwise the file should have a preceding /, which means use this path relative to the hubzilla basedir - files beginning with // are considered to be schemeless URLs. Therefore 'foo.css' means find the best theme-able representation of foo.css. '/library/foo.css' means only use the version of foo.css that is in /library.
Diffstat (limited to 'include')
-rwxr-xr-xinclude/plugin.php32
1 files changed, 21 insertions, 11 deletions
diff --git a/include/plugin.php b/include/plugin.php
index 3a64f67cc..068e482d6 100755
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -598,16 +598,23 @@ function head_get_links() {
function format_css_if_exists($source) {
- $path_prefix = script_path() . '/';
- if (strpos($source[0], '/') !== false) {
- // The source is a URL
- $path = $source[0];
+ // script_path() returns https://yoursite.tld
+
+ $path_prefix = script_path();
+
+ $script = $source[0];
+
+ if(strpos($script, '/') !== false) {
+ // The script is a path relative to the server root
+ $path = $script;
// If the url starts with // then it's an absolute URL
- if($source[0][0] === '/' && $source[0][1] === '/') $path_prefix = '';
+ if(substr($script,0,2) === '//') {
+ $path_prefix = '';
+ }
} else {
// It's a file from the theme
- $path = theme_include($source[0]);
+ $path = '/' . theme_include($script);
}
if($path) {
@@ -697,16 +704,19 @@ function head_get_main_js() {
}
function format_js_if_exists($source) {
- $path_prefix = script_path() . '/';
+ $path_prefix = script_path();
if(strpos($source,'/') !== false) {
- // The source is a URL
+ // The source is a known path on the system
$path = $source;
// If the url starts with // then it's an absolute URL
- if($source[0] === '/' && $source[1] === '/') $path_prefix = '';
- } else {
+ if(substr($source,0,2) === '//') {
+ $path_prefix = '';
+ }
+ }
+ else {
// It's a file from the theme
- $path = theme_include($source);
+ $path = '/' . theme_include($source);
}
if($path) {
$qstring = ((parse_url($path, PHP_URL_QUERY)) ? '&' : '?') . 'v=' . STD_VERSION;