From: Tim Landscheidt Date: Sat, 22 Sep 2012 23:50:52 +0000 (+0000) Subject: Do not flip partial keys in CSSJanus. X-Git-Tag: 1.31.0-rc.0~20948 X-Git-Url: http://git.heureux-cyclage.org/?a=commitdiff_plain;h=ce034ac43060e000a7639fd11c4404153951b6b7;hp=2a4ad3e32cf4f6814554ebcf09ac0250546a2549;p=lhc%2Fweb%2Fwiklou.git Do not flip partial keys in CSSJanus. Change-Id: I1ee9d16069c4627aa81024eeb642714ef796cec5 --- diff --git a/includes/libs/CSSJanus.php b/includes/libs/CSSJanus.php index 4ebbc49718..76c5b6ab5b 100644 --- a/includes/libs/CSSJanus.php +++ b/includes/libs/CSSJanus.php @@ -57,6 +57,7 @@ class CSSJanus { 'lookahead_not_open_brace' => null, 'lookahead_not_closing_paren' => null, 'lookahead_for_closing_paren' => null, + 'lookahead_not_letter' => '(?![a-zA-Z])', 'lookbehind_not_letter' => '(? '[^\}]*?', 'noflip_annotation' => '\/\*\s*@noflip\s*\*\/', @@ -104,8 +105,8 @@ class CSSJanus { $patterns['noflip_class'] = "/({$patterns['noflip_annotation']}{$patterns['chars_within_selector']}})/i"; $patterns['direction_ltr'] = "/({$patterns['direction']})ltr/i"; $patterns['direction_rtl'] = "/({$patterns['direction']})rtl/i"; - $patterns['left'] = "/{$patterns['lookbehind_not_letter']}(left){$patterns['lookahead_not_closing_paren']}{$patterns['lookahead_not_open_brace']}/i"; - $patterns['right'] = "/{$patterns['lookbehind_not_letter']}(right){$patterns['lookahead_not_closing_paren']}{$patterns['lookahead_not_open_brace']}/i"; + $patterns['left'] = "/{$patterns['lookbehind_not_letter']}(left){$patterns['lookahead_not_letter']}{$patterns['lookahead_not_closing_paren']}{$patterns['lookahead_not_open_brace']}/i"; + $patterns['right'] = "/{$patterns['lookbehind_not_letter']}(right){$patterns['lookahead_not_letter']}{$patterns['lookahead_not_closing_paren']}{$patterns['lookahead_not_open_brace']}/i"; $patterns['left_in_url'] = "/{$patterns['lookbehind_not_letter']}(left){$patterns['lookahead_for_closing_paren']}/i"; $patterns['right_in_url'] = "/{$patterns['lookbehind_not_letter']}(right){$patterns['lookahead_for_closing_paren']}/i"; $patterns['ltr_in_url'] = "/{$patterns['lookbehind_not_letter']}(ltr){$patterns['lookahead_for_closing_paren']}/i"; diff --git a/tests/phpunit/includes/libs/CSSJanusTest.php b/tests/phpunit/includes/libs/CSSJanusTest.php index 54f66077a6..2cd86eaf1d 100644 --- a/tests/phpunit/includes/libs/CSSJanusTest.php +++ b/tests/phpunit/includes/libs/CSSJanusTest.php @@ -458,6 +458,16 @@ class CSSJanusTest extends MediaWikiTestCase { ".foo\t{\tleft\t:\t0;}", ".foo\t{\tright\t:\t0;}" ), + + // Guard against partial keys + array( + '.foo { leftxx: 0; }', + '.foo { leftxx: 0; }' + ), + array( + '.foo { rightxx: 0; }', + '.foo { rightxx: 0; }' + ), ); } @@ -534,16 +544,6 @@ class CSSJanusTest extends MediaWikiTestCase { */ function provideTransformBrokenCases() { return array( - // Guard against partial keys - array( - '.foo { leftxx: 0; }', - '.foo { leftxx: 0; }' - ), - array( - '.foo { rightxx: 0; }', - '.foo { rightxx: 0; }' - ), - // Guard against selectors that look flippable array( #