summaryrefslogtreecommitdiff
path: root/lib/exe/css.php
diff options
context:
space:
mode:
authorGerrit Uitslag <klapinklapin@gmail.com>2014-09-28 15:36:21 +0200
committerGerrit Uitslag <klapinklapin@gmail.com>2014-09-28 15:36:21 +0200
commit0c1b02bead38d5a58032a1c88cf3ca53bbc4a4d9 (patch)
treeb9cb574a1964f28dda648795010a5be056b80618 /lib/exe/css.php
parent618191d008b98cb421694c541145c863d7b300ce (diff)
parentda9572711f54d13ce3c5506971154b0bc359723f (diff)
downloadrpg-0c1b02bead38d5a58032a1c88cf3ca53bbc4a4d9.tar.gz
rpg-0c1b02bead38d5a58032a1c88cf3ca53bbc4a4d9.tar.bz2
Merge remote-tracking branch 'origin/master' into FS#2697searchpagereadonly
Conflicts: inc/lang/hr/searchpage.txt inc/lang/ko/searchpage.txt
Diffstat (limited to 'lib/exe/css.php')
-rw-r--r--lib/exe/css.php61
1 files changed, 59 insertions, 2 deletions
diff --git a/lib/exe/css.php b/lib/exe/css.php
index cab7384b2..6c1d60751 100644
--- a/lib/exe/css.php
+++ b/lib/exe/css.php
@@ -56,7 +56,7 @@ function css_out(){
}
// cache influencers
- $tplinc = tpl_basedir($tpl);
+ $tplinc = tpl_incdir($tpl);
$cache_files = getConfigFiles('main');
$cache_files[] = $tplinc.'style.ini';
$cache_files[] = $tplinc.'style.local.ini'; // @deprecated
@@ -133,6 +133,9 @@ function css_out(){
$css = ob_get_contents();
ob_end_clean();
+ // strip any source maps
+ stripsourcemaps($css);
+
// apply style replacements
$css = css_applystyle($css, $styleini['replacements']);
@@ -552,7 +555,7 @@ function css_compress($css){
$css = preg_replace_callback('#(/\*)(.*?)(\*/)#s','css_comment_cb',$css);
//strip (incorrect but common) one line comments
- $css = preg_replace('/(?<!:)\/\/.*$/m','',$css);
+ $css = preg_replace_callback('/^.*\/\/.*$/m','css_onelinecomment_cb',$css);
// strip whitespaces
$css = preg_replace('![\r\n\t ]+!',' ',$css);
@@ -588,4 +591,58 @@ function css_comment_cb($matches){
return $matches[0];
}
+/**
+ * Callback for css_compress()
+ *
+ * Strips one line comments but makes sure it will not destroy url() constructs with slashes
+ *
+ * @param $matches
+ * @return string
+ */
+function css_onelinecomment_cb($matches) {
+ $line = $matches[0];
+
+ $i = 0;
+ $len = strlen($line);
+
+ while ($i< $len){
+ $nextcom = strpos($line, '//', $i);
+ $nexturl = stripos($line, 'url(', $i);
+
+ if($nextcom === false) {
+ // no more comments, we're done
+ $i = $len;
+ break;
+ }
+
+ // keep any quoted string that starts before a comment
+ $nextsqt = strpos($line, "'", $i);
+ $nextdqt = strpos($line, '"', $i);
+ if(min($nextsqt, $nextdqt) < $nextcom) {
+ $skipto = false;
+ if($nextsqt !== false && ($nextdqt === false || $nextsqt < $nextdqt)) {
+ $skipto = strpos($line, "'", $nextsqt+1) +1;
+ } else if ($nextdqt !== false) {
+ $skipto = strpos($line, '"', $nextdqt+1) +1;
+ }
+
+ if($skipto !== false) {
+ $i = $skipto;
+ continue;
+ }
+ }
+
+ if($nexturl === false || $nextcom < $nexturl) {
+ // no url anymore, strip comment and be done
+ $i = $nextcom;
+ break;
+ }
+
+ // we have an upcoming url
+ $i = strpos($line, ')', $nexturl);
+ }
+
+ return substr($line, 0, $i);
+}
+
//Setup VIM: ex: et ts=4 :