[wp-trac] [WordPress Trac] #40817: WordCounter removeRegExp maybe broken
WordPress Trac
noreply at wordpress.org
Fri May 19 09:16:05 UTC 2017
#40817: WordCounter removeRegExp maybe broken
----------------------------------------+-----------------------------
Reporter: DrLightman | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Editor | Version: 4.6.4
Severity: normal | Keywords:
Focuses: javascript, administration |
----------------------------------------+-----------------------------
In the file \wp-admin\js\word-count.js at around line 27 of my WP 4.6.6
there is the removeRegExp for WordCounter.prototype.settings:
{{{
removeRegExp: new RegExp( [
'[',
// Basic Latin (extract)
'\u0021-\u0040\u005B-\u0060\u007B-\u007E',
// Latin-1 Supplement (extract)
'\u0080-\u00BF\u00D7\u00F7',
// General Punctuation
// Superscripts and Subscripts
// Currency Symbols
// Combining Diacritical Marks for Symbols
// Letterlike Symbols
// Number Forms
// Arrows
// Mathematical Operators
// Miscellaneous Technical
// Control Pictures
// Optical Character Recognition
// Enclosed Alphanumerics
// Box Drawing
// Block Elements
// Geometric Shapes
// Miscellaneous Symbols
// Dingbats
// Miscellaneous Mathematical Symbols-A
// Supplemental Arrows-A
// Braille Patterns
// Supplemental Arrows-B
// Miscellaneous Mathematical Symbols-B
// Supplemental Mathematical Operators
// Miscellaneous Symbols and Arrows
'\u2000-\u2BFF',
// Supplemental Punctuation
'\u2E00-\u2E7F',
']'
].join( '' ), 'g' ),
}}}
But according to Javascript docs https://developer.mozilla.org/en-
US/docs/Web/JavaScript/Reference/Global_Objects/RegExp when using string
notation the backslashes should be escaped:
When using the constructor function, the normal string escape rules
(preceding special characters with \ when included in a string) are
necessary. For example, the following are equivalent:
`var re = /\w+/;`
`var re = new RegExp('\\w+');`
So shouldn't be this the correct way to build that regexp since it uses
the second way with the string, with `\\u` in place of `\u`?
{{{
removeRegExp: new RegExp( [
'[',
// Basic Latin (extract)
'\\u0021-\\u0040\\u005B-\\u0060\\u007B-\\u007E',
// Latin-1 Supplement (extract)
'\\u0080-\\u00BF\\u00D7\\u00F7',
// General Punctuation
// Superscripts and Subscripts
// Currency Symbols
// Combining Diacritical Marks for Symbols
// Letterlike Symbols
// Number Forms
// Arrows
// Mathematical Operators
// Miscellaneous Technical
// Control Pictures
// Optical Character Recognition
// Enclosed Alphanumerics
// Box Drawing
// Block Elements
// Geometric Shapes
// Miscellaneous Symbols
// Dingbats
// Miscellaneous Mathematical Symbols-A
// Supplemental Arrows-A
// Braille Patterns
// Supplemental Arrows-B
// Miscellaneous Mathematical Symbols-B
// Supplemental Mathematical Operators
// Miscellaneous Symbols and Arrows
'\\u2000-\\u2BFF',
// Supplemental Punctuation
'\\u2E00-\\u2E7F',
']'
].join( '' ), 'g' ),
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40817>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list