r63429 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63428‎ | r63429 | r63430 >
Date:22:34, 8 March 2010
Author:tstarling
Status:ok
Tags:
Comment:
MFT r63424 (CSS validation issue) plus release notes.
Modified paths:
  • /branches/REL1_15/phase3/RELEASE-NOTES (modified) (history)
  • /branches/REL1_15/phase3/includes/Sanitizer.php (modified) (history)
  • /branches/REL1_15/phase3/maintenance/parserTests.txt (modified) (history)

Diff [purge]

Index: branches/REL1_15/phase3/maintenance/parserTests.txt
@@ -4357,7 +4357,24 @@
43584358
43594359 !! end
43604360
 4361+!! test
 4362+CSS line continuation 1
 4363+!! input
 4364+<div style="background-image: u\&#10;rl(test.jpg);"></div>
 4365+!! result
 4366+<div></div>
43614367
 4368+!! end
 4369+
 4370+!! test
 4371+CSS line continuation 2
 4372+!! input
 4373+<div style="background-image: u\&#13;rl(test.jpg); "></div>
 4374+!! result
 4375+<div></div>
 4376+
 4377+!! end
 4378+
43624379 !! article
43634380 Template:Identity
43644381 !! text
Index: branches/REL1_15/phase3/includes/Sanitizer.php
@@ -658,24 +658,48 @@
659659 * @return mixed
660660 */
661661 static function checkCss( $value ) {
662 - $stripped = Sanitizer::decodeCharReferences( $value );
 662+ $value = Sanitizer::decodeCharReferences( $value );
663663
664664 // Remove any comments; IE gets token splitting wrong
665 - $stripped = StringUtils::delimiterReplace( '/*', '*/', ' ', $stripped );
 665+ $value = StringUtils::delimiterReplace( '/*', '*/', ' ', $value );
666666
667 - $value = $stripped;
668 -
669 - // ... and continue checks
670 - $stripped = preg_replace( '!\\\\([0-9A-Fa-f]{1,6})[ \\n\\r\\t\\f]?!e',
671 - 'codepointToUtf8(hexdec("$1"))', $stripped );
672 - $stripped = str_replace( '\\', '', $stripped );
673 - if( preg_match( '/(?:expression|tps*:\/\/|url\\s*\().*/is',
674 - $stripped ) ) {
675 - # haxx0r
 667+ // Decode escape sequences and line continuation
 668+ // See the grammar in the CSS 2 spec, appendix D, Mozilla implements it accurately.
 669+ // IE 8 doesn't implement it at all, but there's no way to introduce url() into
 670+ // IE that doesn't hit Mozilla also.
 671+ static $decodeRegex;
 672+ if ( !$decodeRegex ) {
 673+ $space = '[\\x20\\t\\r\\n\\f]';
 674+ $nl = '(?:\\n|\\r\\n|\\r|\\f)';
 675+ $backslash = '\\\\';
 676+ $decodeRegex = "/ $backslash
 677+ (?:
 678+ ($nl) | # 1. Line continuation
 679+ ([0-9A-Fa-f]{1,6})$space? | # 2. character number
 680+ (.) # 3. backslash cancelling special meaning
 681+ )/xu";
 682+ }
 683+ $decoded = preg_replace_callback( $decodeRegex,
 684+ array( __CLASS__, 'cssDecodeCallback' ), $value );
 685+ if ( preg_match( '!expression|https?://|url\s*\(!i', $decoded ) ) {
 686+ // Not allowed
676687 return false;
 688+ } else {
 689+ // Allowed, return CSS with comments stripped
 690+ return $value;
677691 }
 692+ }
678693
679 - return $value;
 694+ static function cssDecodeCallback( $matches ) {
 695+ if ( $matches[1] !== '' ) {
 696+ return '';
 697+ } elseif ( $matches[2] !== '' ) {
 698+ return codepointToUtf8( hexdec( $matches[2] ) );
 699+ } elseif ( $matches[3] !== '' ) {
 700+ return $matches[3];
 701+ } else {
 702+ throw new MWException( __METHOD__.': invalid match' );
 703+ }
680704 }
681705
682706 /**
Index: branches/REL1_15/phase3/RELEASE-NOTES
@@ -26,6 +26,8 @@
2727 * (bug 21150) SQLite no longer raise an error when deleting files
2828 * (bug 20880) Fixed updater failure on SQLite backend
2929 * upgrade1_5.php now requires to be run --update option to prevent confusion
 30+* Fixed a CSS validation issue which allowed external images to be included
 31+ into wikis where that is disallowed by configuration.
3032
3133 === Changes since 1.15.0 ===
3234

Follow-up revisions

RevisionCommit summaryAuthorDate
r63433Merge r63429 RELEASE-NOTES to 1.16 HISTORYdemon22:40, 8 March 2010
r63434Merge r63429 RELEASE-NOTES to trunk HISTORYdemon22:40, 8 March 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r63424Fixed CSS validation issue (no handling for line continuation). Reported by S...tstarling22:22, 8 March 2010

Status & tagging log