Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#14046 closed defect (fixed)

dojo.data.ObjectStore 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:

Description

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

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, "~@~").replace(/\\\?/g, "~#~");
s = dojo.regexp.escapeString(s, "*?").replace(/\*/g, '.*').replace(/\?/g, '.');
s = s.replace(/~#~/g,"\\?").replace(/~@~/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?

Thanks.

Change History (2)

comment:1 Changed 8 years ago by Kris Zyp

Resolution: fixed
Status: newclosed

In [27492]:

Fix dojo.data string to regex conversion, fixes #14046 !strict

comment:2 Changed 8 years ago by bill

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