Bug #50491
closedconcatenateCSS sometimes produces invalid css with @charset or @import
100%
Description
I have the following css file:
@import url(http://fonts.googleapis.com/css?family=Open+Sans:400italic,400,600,700,300); @import url(http://fonts.googleapis.com/css?family=Open+Sans+Condensed:700); * { padding: 0; margin: 0; } body { font-family: "Open Sans", Arial, Helvetica, sans-serif; font-size: 0.81em; background: #ffffff; color: #2f2f31; } ...
Note the import urls without quotes and the font-family definition with quotes. As this is concatenated with the generated ones of plugin.###._CSS_DEFAULT_STYLE it becomes
/* moved by compressor */ @import url(http://fonts.googleapis.com/css?family=Open+Sans:400italic,400,600,700,300); @import url(http://fonts.googleapis.com/css?family=Open+Sans+Condensed:700); * { padding: 0; margin: 0; } body { font-family: "Open Sans", Arial, Helvetica, sans-serif; /* default styles for extension "tx_cssstyledcontent" */ /* Headers */ .csc-header-alignment-center { text-align: center; } .csc-header-alignment-right { text-align: right; } ... table.contenttable-color-244 { background-color: silver; } font-size: 0.81em; background: #ffffff; color: #2f2f31; } ...
as it tries to move the @-rules to the top. The output should be
/* moved by compressor */ @import url(http://fonts.googleapis.com/css?family=Open+Sans:400italic,400,600,700,300); /* moved by compressor */ @import url(http://fonts.googleapis.com/css?family=Open+Sans+Condensed:700); /* default styles for extension "tx_cssstyledcontent" */ /* Headers */ .csc-header-alignment-center { text-align: center; } .csc-header-alignment-right { text-align: right; } .csc-header-alignment-left { text-align: left; } ... table.contenttable-color-244 { background-color: silver; } * { padding: 0; margin: 0; } body { font-family: "Open Sans", Arial, Helvetica, sans-serif; font-size: 0.81em; background: #ffffff; color: #2f2f31; } ...
The solution is easy: Make the matching for the @-rule's content less greedy by replacing the pattern
/@(charset|import|namespace)\\s*(url)?\\s*\\(?\\s*["\']?[^"\']+["\']?\\s*\\)?.*;/i
with
/@(charset|import|namespace)\\s*(url)?\\s*\\(?\\s*["\']?[^"\']+?["\']?\\s*\\)?.*;/i
Note the additional "?" after the "+".
The actual problem here is, that the import urls are not quoted, so the pattern matches down to the quote in the font-family definition in the body rule. This function was introduced in TYPO4 4.6. As it is located in t3lib_compressor before 6.0 and 4.6 is already deprecated and 4.7 will be in October, I would patch this for 6.0 - 6.2.
Updated by Gerrit Code Review over 11 years ago
- Status changed from New to Under Review
Patch set 2 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/22623
Updated by Gerrit Code Review over 11 years ago
Patch set 3 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/22623
Updated by Gerrit Code Review about 11 years ago
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/22623
Updated by Gerrit Code Review about 11 years ago
Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/22623
Updated by Gerrit Code Review almost 11 years ago
Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/22623
Updated by Stefan Neufeind almost 11 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 9c16871a9e990797bedb3cc883d50867a35ad1cd.