Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#14046 closed defect (fixed) fetch and regular expressions

Reported by: rmaccracken Owned by: Kris Zyp
Priority: high Milestone: 1.8
Component: Data Version: 1.6.1
Keywords: Cc:
Blocked By: Blocking:


I'm having problems with handling some special characters using dijit.form.FilteringSelect? with a store wrapped by Digging deeper, you can see the following code in the fetch method of

query[i] = RegExp("^" + dojo.regexp.escapeString(required, "*?").replace(/\*/g, '.*').replace(/\?/g, '.') + "$", args.queryOptions && args.queryOptions.ignoreCase ? "mi" : "m");

If I enter *, ?, or \ into the filtering select control, the above code converts the query into an odd regular expression and does not seem to work.

The following code does work though:

var s = required.replace(/\\\\/g, "~!~").replace(/\\\*/g, "[email protected]~").replace(/\\\?/g, "~#~");
s = dojo.regexp.escapeString(s, "*?").replace(/\*/g, '.*').replace(/\?/g, '.');
s = s.replace(/~#~/g,"\\?").replace(/[email protected]~/g,"\\*").replace(/~!~/g,"\\\\");
query[i] = RegExp("^" + s + "$", args.queryOptions && args.queryOptions.ignoreCase ? "mi" : "m");

I can't say I like this code, but it does seem to work. It basically converts the special characters into something else, then executes the existing code, then converts back to the special characters.

So, am I just using this wrong, or is this a defect? If it is a defect, is there a better way to fix it?


Change History (2)

comment:1 Changed 10 years ago by Kris Zyp

Resolution: fixed
Status: newclosed

In [27492]:

Fix string to regex conversion, fixes #14046 !strict

comment:2 Changed 10 years ago by bill

Milestone: tbd1.8
Note: See TracTickets for help on using tickets.