Skip to content

Commit 3d4cb85

Browse files
committed
Ensure that the true hyphen is an allowed combining mark
1 parent 58a395a commit 3d4cb85

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

src/fixes/node-fixes/class-dewidow-fix.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
*/
4343
class Dewidow_Fix extends Abstract_Node_Fix {
4444
const SPACE_BETWEEN = '[\s]+'; // \s includes all special spaces (but not ZWSP) with the u flag.
45-
const WIDOW = '[\w\p{M}\-' . U::ZERO_WIDTH_SPACE . U::SOFT_HYPHEN . ']+?'; // \w includes all alphanumeric Unicode characters but not composed characters.
45+
const WIDOW = '[\w\p{M}\-' . U::HYPHEN . U::ZERO_WIDTH_SPACE . U::SOFT_HYPHEN . ']+?'; // \w includes all alphanumeric Unicode characters but not composed characters.
4646

4747
// Mandatory UTF-8 modifer.
4848
const REGEX_START = '/

src/fixes/node-fixes/class-style-caps-fix.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,27 +71,29 @@ class Style_Caps_Fix extends Simple_Style_Fix {
7171
// Servers with PCRE compiled without "--enable-unicode-properties" fail at \p{Lu} by returning an empty string (this leaving the screen void of text
7272
// thus are testing this alternative.
7373
const REGEX = '/
74-
(?<![\w\-_' . U::ZERO_WIDTH_SPACE . U::SOFT_HYPHEN . ']) # negative lookbehind assertion
74+
(?<![\w' . self::COMBINING_MARKS . ']) # negative lookbehind assertion
7575
(
7676
(?: # CASE 1: " 9A "
7777
[0-9]+ # starts with at least one number
78-
(?:\-|_|' . U::ZERO_WIDTH_SPACE . '|' . U::SOFT_HYPHEN . ')*
78+
(?:[' . self::COMBINING_MARKS . '])*
7979
# may contain hyphens, underscores, zero width spaces, or soft hyphens,
8080
[A-ZÀ-ÖØ-Ý] # but must contain at least one capital letter
81-
(?:[A-ZÀ-ÖØ-Ý]|[0-9]|\-|_|' . U::ZERO_WIDTH_SPACE . '|' . U::SOFT_HYPHEN . ')*
81+
(?:[A-ZÀ-ÖØ-Ý]|[0-9]|[' . self::COMBINING_MARKS . '])*
8282
# may be followed by any number of numbers capital letters, hyphens, underscores, zero width spaces, or soft hyphens
8383
)
8484
|
8585
(?: # CASE 2: " A9 "
8686
[A-ZÀ-ÖØ-Ý] # starts with capital letter
8787
(?:[A-ZÀ-ÖØ-Ý]|[0-9]) # must be followed a number or capital letter
88-
(?:[A-ZÀ-ÖØ-Ý]|[0-9]|\-|_|' . U::ZERO_WIDTH_SPACE . '|' . U::SOFT_HYPHEN . ')*
88+
(?:[A-ZÀ-ÖØ-Ý]|[0-9]|[' . self::COMBINING_MARKS . '])*
8989
# may be followed by any number of numbers capital letters, hyphens, underscores, zero width spaces, or soft hyphens
9090
)
9191
)
92-
(?![\w\-_' . U::ZERO_WIDTH_SPACE . U::SOFT_HYPHEN . ']) # negative lookahead assertion
92+
(?![\w' . self::COMBINING_MARKS . ']) # negative lookahead assertion
9393
/Sxu';
9494

95+
const COMBINING_MARKS = '\-_' . U::HYPHEN . U::SOFT_HYPHEN . U::ZERO_WIDTH_SPACE; // Needs to be part of character class.
96+
9597
/**
9698
* Creates a new node fix with a class.
9799
*

tests/class-php-typography-test.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ public function provide_process_data() {
496496
[ '<p>Line One <br>Line Two,<br><span>Line Three.</span></p>', '<p>Line One <br>Line Two,<br><span>Line Three.</span></p>', false ],
497497
[ '3/4 of 10/12/89', '<sup class="numerator"><span class="numbers">3</span></sup>&frasl;<sub class="denominator"><span class="numbers">4</span></sub> of <span class="numbers">10</span>/<span class="numbers">12</span>/<span class="numbers">89</span>', false ],
498498
[ 'Certain HTML entities', 'Cer&shy;tain <span class="caps">HTML</span> entities', false ],
499+
[ 'during WP-CLI commands', 'dur&shy;ing <span class="caps">WP-CLI</span> commands', false ],
499500
];
500501
}
501502

tests/fixes/node-fixes/class-style-caps-fix-test.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public function provide_style_caps_data() {
5959
[ 'foo BARbaz', 'foo BARbaz' ],
6060
[ 'foo BAR123 baz', 'foo <span class="caps">BAR123</span> baz' ],
6161
[ 'foo 123BAR baz', 'foo <span class="caps">123BAR</span> baz' ],
62+
[ 'during WP-CLI commands', 'during <span class="caps">WP-CLI</span> commands' ],
63+
[ 'during WP‐CLI commands', 'during <span class="caps">WP‐CLI</span> commands' ], // HYPHEN instead of HYPHEN-MINUS.
6264
];
6365
}
6466

0 commit comments

Comments
 (0)