#7151 closed defect (fixed)
FilteringSelect: problem with \(backslash)
Reported by: | fms | Owned by: | bill |
---|---|---|---|
Priority: | high | Milestone: | 1.2 |
Component: | Dijit - Form | Version: | 1.1.1 |
Keywords: | FilteringSelect backslash | Cc: | |
Blocked By: | Blocking: |
Description
When selecting an item that contains a '\'(backslash) from FilteringSelect?, 'The value entered is not valid' is shown even though it is valid.
In 1.1.1, the problem occurs with FilteringSelect?, and a data store other than dijit.form._ComboBoxDataStore(default), such as dojo.data.ItemFileReadStore?.
dijit.form._ComboBoxDataStore escapes meta characters of RegExp?() on its own, whereas other data stores use dojo.data.util.filter.patternToRegExp() instead.
In trunk(r14389), the problem occurs with FilteringSelect? and any data store, including dijit.form._ComboBoxDataStore.
In the changeset r14220, dijit.form._ComboBoxDataStore has been fixed to escape meta characters using dojo.data.util.filter.patternToRegExp() just like other data stores, making the same problem to occur in dijit.form._ComboBoxDataStore as well.
Since '\' is a meta character of dojo.data.util.filter.patternToRegExp(), '\'s in the label of FilteringSelect? must be escaped.
Sample patches to both revisions are attached.
Regards, [email protected]…
Attachments (2)
Change History (10)
comment:1 Changed 13 years ago by
Changed 13 years ago by
Attachment: | patch-filteringselect-backslash-r14388.udiff added |
---|
comment:2 Changed 13 years ago by
I think dojo.data.util.filter.patternToRegExp() itself is working correctly in that it converts a "pattern" string containing "*" and "?" using "\" as the escape character into a RegExp? with ".*" and ".", respectively. FilteringSelect? indirectly uses dojo.data.util.filter.patternToRegExp() as a result of a sequence of function calls, so as long as such call sequence is maintained, the "pattern" needs to be specified in a manner that dojo.data.util.filter.patternToRegExp() expects.
I made an additional correction to the code, and replaced the previous code with the new one.
Changed 13 years ago by
Attachment: | patch-filteringselect-backslash-1.1.1.udiff added |
---|
comment:3 Changed 13 years ago by
Milestone: | tbd → 1.3 |
---|---|
Owner: | set to haysmark |
Hmm, Mark, what do you think?
Extrapolating from this ticket description it seems like if you select "3 * 5" from the drop down list it should show up in the <input> box as "3 \* 5". IE, that \, *, and . need to be escaped to form a pattern.
I'm torn though... because it would also be nice if the <input> box displayed exactly what the user selected (so they don't get confused).
comment:4 Changed 13 years ago by
PS: and how does this affect the value submitted with the form? We want "3 * 5" to be submitted, not "3 \* 5".
comment:5 Changed 13 years ago by
The main problem is that if you select an item
<option value="val1">some\doc\folder1</option>
from a drop-down list
<select dojoType="dijit.form.FilteringSelect"> <option value="val1">some\doc\folder1</option> <option value="val2">some\doc\folder2</option> </select>,
an error "The value entered is not valid" occurs, and nothing goes into the .value property after r14220, and the same error occurs with 1.1.1 when the FilteringSelect? is connected to dojo.data.ItemFileReadStore? which contains data like above. The string "some\document\folder1" should still be displayed in the drop down-list, but this error shouldn't occur.
In order to fix the problem and stop this error to occur, I escaped the string just before it gets passed to dojo.data.util.filter.patternToRegExp(), so the string that is displayed, as well as the one that goes into the .value property remains in the original form (i.e. no escape).
I hope this clarifies my point.
It may be necessary to revisit the overall design of FilteringSelect?, ComboBox?, "pattern", and RegExp?, but in the meantime, I stongly believe this fix at least needs to be reflected in 1.1, because it affects because it affects everyone that uses FilteringSelect? with a special data store other than dijit.form._ComboBoxDataStore. Moreover, r14220 is making this to affect everyone that uses FilteringSelect? with any data store including dijit.form._ComboBoxDataStore(default).
comment:6 Changed 13 years ago by
Milestone: | 1.3 → 1.2 |
---|---|
Owner: | changed from haysmark to bill |
Status: | new → assigned |
Oh I see... yah that makes sense, I'll check in.
comment:7 Changed 13 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
(In [14477]) Fixes #7151: FilteringSelect? problem where the field goes yellow after selecting something from the drop down with a backslash, and then tabbing away. !strict
comment:8 Changed 10 years ago by
Component: | Dijit → Dijit - Form |
---|
Isn't the real problem in dojo.data.util.filter.patternToRegExp() ?