#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, "[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?
Thanks.
Change History (2)
comment:1 Changed 9 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:2 Changed 9 years ago by
Milestone: | tbd → 1.8 |
---|
In [27492]: