Ticket #28718: miqro-28718.patch
| File miqro-28718.patch, 7.5 KB (added by , 12 years ago) |
|---|
-
src/wp-includes/formatting.php
104 104 105 105 // '99' and '99" are ambiguous among other patterns; assume it's an abbreviated year at the end of a quotation. 106 106 if ( "'" !== $apos || "'" !== $closing_single_quote ) { 107 $dynamic[ '/\'(\d\d)\'(?=\Z|[.,)} >\-\]]|' . $spaces . ')/' ] = $apos . '$1' . $closing_single_quote;107 $dynamic[ '/\'(\d\d)\'(?=\Z|[.,)}\-\]]|>|' . $spaces . ')/' ] = $apos . '$1' . $closing_single_quote; 108 108 } 109 110 109 if ( "'" !== $apos || '"' !== $closing_quote ) { 111 $dynamic[ '/\'(\d\d)"(?=\Z|[.,)} >\-\]]|' . $spaces . ')/' ] = $apos . '$1' . $closing_quote;110 $dynamic[ '/\'(\d\d)"(?=\Z|[.,)}\-\]]|>|' . $spaces . ')/' ] = $apos . '$1' . $closing_quote; 112 111 } 113 112 114 113 // '99 '99s '99's (apostrophe) But never '9 or '99% or '999 or '99.0. … … 126 125 127 126 // Single quote at start, or preceded by (, {, <, [, ", -, or spaces. 128 127 if ( "'" !== $opening_single_quote ) { 129 $dynamic[ '/(?<=\A|[([{ <"\-]|' . $spaces . ')\'/' ] = $opening_single_quote;128 $dynamic[ '/(?<=\A|[([{"\-]|<|' . $spaces . ')\'/' ] = $opening_single_quote; 130 129 } 131 130 132 131 // Apostrophe in a word. No spaces, double apostrophes, or other punctuation. 133 132 if ( "'" !== $apos ) { 134 $dynamic[ '/(?<!' . $spaces . ')\'(?!\Z|[.,:;"\'(){} <>[\]\-]|' . $spaces . ')/' ] = $apos;133 $dynamic[ '/(?<!' . $spaces . ')\'(?!\Z|[.,:;"\'(){}[\]\-]|&[lg]t;|' . $spaces . ')/' ] = $apos; 135 134 } 136 135 137 136 // 9" (double prime) … … 146 145 147 146 // Double quote at start, or preceded by (, {, <, [, -, or spaces, and not followed by spaces. 148 147 if ( '"' !== $opening_quote ) { 149 $dynamic[ '/(?<=\A|[([{ <\-]|' . $spaces . ')"(?!' . $spaces . ')/' ] = $opening_quote;148 $dynamic[ '/(?<=\A|[([{\-]|<|' . $spaces . ')"(?!' . $spaces . ')/' ] = $opening_quote; 150 149 } 151 150 152 151 // Any remaining double quotes. … … 156 155 157 156 // Single quotes followed by spaces or ending punctuation. 158 157 if ( "'" !== $closing_single_quote ) { 159 $dynamic[ '/\'(?=\Z|[.,)} >\-\]]|' . $spaces . ')/' ] = $closing_single_quote;158 $dynamic[ '/\'(?=\Z|[.,)}\-\]]|>|' . $spaces . ')/' ] = $closing_single_quote; 160 159 } 161 160 162 161 // Dashes and spaces -
tests/phpunit/tests/formatting/WPTexturize.php
117 117 $this->assertEquals('‘Class of ’99’s’', wptexturize("'Class of '99’s'")); 118 118 //$this->assertEquals('“Class of 99”', wptexturize("\"Class of 99\"")); 119 119 $this->assertEquals('“Class of ’99”', wptexturize("\"Class of '99\"")); 120 $this->assertEquals('{“Class of ’99”}', wptexturize("{\"Class of '99\"}")); 121 $this->assertEquals(' “Class of ’99” ', wptexturize(" \"Class of '99\" ")); 122 $this->assertEquals('}“Class of ’99”{', wptexturize("}\"Class of '99\"{")); // Not a quotation, may be between two other quotations. 120 123 } 121 124 122 125 function test_quotes_after_numbers() { … … 346 349 "word [‘word word", 347 350 ), 348 351 array( 349 "word <'word word", // Invalid HTML input ?350 "word <̵ 6;word word",352 "word <'word word", // Invalid HTML input triggers the apos in a word pattern. 353 "word <’word word", 351 354 ), 352 355 array( 353 "word <'word word", // Valid HTML input triggers the apos in a word pattern354 "word <̵ 7;word word",356 "word <'word word", // Valid HTML input makes curly quotes. 357 "word <‘word word", 355 358 ), 356 359 array( 357 360 "word {'word word", … … 375 378 ), 376 379 array( 377 380 "word<'word word", 378 "word<̵ 6;word word",381 "word<’word word", 379 382 ), 380 383 array( 381 384 "word<'word word", 382 "word<̵ 7;word word",385 "word<‘word word", 383 386 ), 384 387 array( 385 388 "word{'word word", … … 402 405 "word [‘ word word", 403 406 ), 404 407 array( 405 "word <' word word", // Invalid HTML input?406 "word <̵ 6; word word",408 "word <' word word", 409 "word <’ word word", 407 410 ), 408 411 array( 409 "word <' word word", // Valid HTML input triggers the closing single quote here410 "word <̵ 7; word word",412 "word <' word word", 413 "word <‘ word word", 411 414 ), 412 415 array( 413 416 "word {' word word", … … 431 434 ), 432 435 array( 433 436 "word<' word word", 434 "word<̵ 6; word word",437 "word<’ word word", 435 438 ), 436 439 array( 437 440 "word<' word word", 438 "word<̵ 7; word word",441 "word<‘ word word", 439 442 ), 440 443 array( 441 444 "word{' word word", … … 533 536 "word word’s word", 534 537 ), 535 538 array( 536 "word word'. word", // Quotes with outside punctuation could end with apostrophes instead of closing quotes (may affect i18n)537 "word word’.word",539 "word'[ word", // Apostrophes are never followed by opening punctuation. 540 "word'[ word", 538 541 ), 539 542 array( 540 "word ]'.word",541 "word ]’.word",543 "word'( word", 544 "word'( word", 542 545 ), 543 546 array( 544 "word )'.word",545 "word )’.word",547 "word'{ word", 548 "word'{ word", 546 549 ), 547 550 array( 548 "word }'.word",549 "word }’.word",551 "word'< word", 552 "word'< word", 550 553 ), 551 554 array( 552 "word >'. word", // Not tested553 "word >’.word",555 "word'< word", // Invalid HTML input does trigger the apos pattern. 556 "word’< word", 554 557 ), 555 array(556 "word >'. word",557 "word >’. word",558 ),559 558 ); 560 559 } 561 560 562 561 /** 563 * Double quote after a space or ([ {< becomes “ (opening_quote) if not followed by spaces562 * Double quote after a space or ([-{< becomes “ (opening_quote) if not followed by spaces 564 563 * 565 564 * Checks all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. 566 565 * … … 586 585 'word [“word word', 587 586 ), 588 587 array( 589 'word <"word word', // Invalid HTML input ?590 'word <̶ 0;word word',588 'word <"word word', // Invalid HTML input triggers the closing quote pattern. 589 'word <”word word', 591 590 ), 592 591 array( 593 'word <"word word', // Valid HTML input triggers the closing quote pattern594 'word <̶ 1;word word',592 'word <"word word', 593 'word <“word word', 595 594 ), 596 595 array( 597 596 'word {"word word', … … 598 597 'word {“word word', 599 598 ), 600 599 array( 600 'word -"word word', 601 'word -“word word', 602 ), 603 array( 604 'word-"word word', 605 'word-“word word', 606 ), 607 array( 601 608 '"word word', 602 609 '“word word', 603 610 ), … … 698 705 } 699 706 700 707 /** 701 * Test that single quotes followed by a space or a periodbecome ’ (closing_single_quote)708 * Test that single quotes followed by a space or .,-)}]> become ’ (closing_single_quote) 702 709 * 703 710 * Checks all baseline patterns. If anything ever changes in wptexturize(), these tests may fail. 704 711 * … … 728 735 "word word’, she said", 729 736 ), 730 737 array( 738 "word word'- word", 739 "word word’- word", 740 ), 741 array( 742 "word word') word", 743 "word word’) word", 744 ), 745 array( 746 "word word'} word", 747 "word word’} word", 748 ), 749 array( 750 "word word'] word", 751 "word word’] word", 752 ), 753 array( 754 "word word'> word", 755 "word word’> word", 756 ), 757 array( 731 758 "word word'", 732 759 "word word’", 733 760 ),
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)