diff options
| author | Josh Woody <a_jelly_doughnut@phpbb.com> | 2010-08-20 15:37:48 -0500 |
|---|---|---|
| committer | Josh Woody <a_jelly_doughnut@phpbb.com> | 2010-08-20 16:02:58 -0500 |
| commit | c3a5fd30eea8b5426adfc9318d6e6b89616bc071 (patch) | |
| tree | 26b7ff6c90149288613ebac8711d0541eeb60dd5 | |
| parent | 64e6faa877af36f256da12d122e296f45706d359 (diff) | |
| download | forums-c3a5fd30eea8b5426adfc9318d6e6b89616bc071.tar forums-c3a5fd30eea8b5426adfc9318d6e6b89616bc071.tar.gz forums-c3a5fd30eea8b5426adfc9318d6e6b89616bc071.tar.bz2 forums-c3a5fd30eea8b5426adfc9318d6e6b89616bc071.tar.xz forums-c3a5fd30eea8b5426adfc9318d6e6b89616bc071.zip | |
[ticket/9646] Honor CSS comments in @import statements
Add a basic CSS comment parser that allows comments to prevent loading an
@import statement. For simplicity, only whitespace is allowed between /* and
the @import. Also adjust regex to not parse improper quotation marks.
PHPBB3-9646
PHPBB3-8169
| -rw-r--r-- | phpBB/includes/acp/acp_styles.php | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index 3310560c73..95b700c876 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -2531,13 +2531,21 @@ parse_css_file = {PARSE_CSS_FILE} // Match CSS imports $matches = array(); - preg_match_all('/@import url\(["\'](.*)["\']\);/i', $stylesheet, $matches); + preg_match_all('/@import url\((["\'])(.*)\1\);/i', $stylesheet, $matches); + + // remove commented stylesheets (very simple parser, allows only whitespace + // around an @import statement) + preg_match_all('#/\*\s*@import url\((["\'])(.*)\1\);\s\*/#i', $stylesheet, $commented); + $matches[2] = array_diff($matches[2], $commented[2]); if (sizeof($matches)) { foreach ($matches[0] as $idx => $match) { - $stylesheet = str_replace($match, acp_styles::load_css_file($theme_row['theme_path'], $matches[1][$idx]), $stylesheet); + if (isset($matches[2][$idx])) + { + $stylesheet = str_replace($match, acp_styles::load_css_file($theme_row['theme_path'], $matches[2][$idx]), $stylesheet); + } } } |
