Page MenuHomePhabricator

$.escapeRE shouldn't escape all uppercase and numbers
Closed, ResolvedPublic

Description

Currently

$.escapeRE('ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890')

is returning

'\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z\1\2\3\4\5\6\7\8\9\0'

but it should not escape any letters.

I think it is necessary to escape the '-' in the regex:

/([\\{}()|.?*+-\^$\[\]])/g

because it is probably being understood as the interval from '+' to '\'.


Version: 1.17.x
Severity: enhancement

Details

Reference
bz27960

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:27 PM
bzimport set Reference to bz27960.

a.d.bergi wrote:

Another possibility would be to push the - to the end of the expression:

/([\\{}()|.?*+^$[\]-])/g

It only escapes capitals though, not lowercase characters.

The javascript test suite contains lower case characters to make sure normal characters aren't escaped. I'll fix this asap and update the tests to include all a-z A-Z and 0-9 for false positives.

Was a regression because of r83284 (which fixed bug 27848).

Fixed in r83610, also added tests to easily catch these regressions in the future before they're committed.

Check the test suite on a a wiki running trunk:

TranslateWiki.net for example
http://translatewiki.net/wiki/Special:BlankPage?action=mwutiltest&debug=true

(second heading "Prototype functions added by MediaWiki")