-
26 Apr 2007 12:42 PM #1
[CLOSED] ComboBox html encoding
[CLOSED] ComboBox html encoding
If I have an item inside of my combo box with '&' in it, it's shown correctly.
However, once that item is selected, the combobox value displays & instead.
I could manually htmlunencode the value, but the extra encoding isn't needed, surely?
-
28 Aug 2007 9:58 AM #2
Bump
Anyone have a fix for this?
-
28 Aug 2007 10:58 AM #3
I was trying to put some &'s in my combos (Ext 1.1 and also Ext svn 876) but I was not able to reproduce it.
Do you have a link where I could see it?Jozef Sakalos, aka Saki
A lot of valuable info at:
Saki's Extensions and Plugins
Saki's Extensions and Plugins Docs
Saki's Examples, Latest: Grid in Card Layout
Saki's Blog, Featured: Writing a Big Application in Ext, Latest: Grid MultiSearch Plugin Video
-
29 Aug 2007 12:20 PM #4
It happens when you htmlEncode the strings on the way down (in case the user put html into the strings
I can't put up a public page, but you can reproduce it pretty easily.
If you go to:
http://extjs.com/deploy/ext/examples/form/combos.html
(or if you have a local build)
C:\apps\www\deploy\ext-2.0\examples\form\combos.html
In the states.js file in that directory, instead of
do:Code:Ext.exampledata.states = [ ['AL', 'Alabama'], ['AK', 'Alaska'], ['AZ', 'Arizona'] ]
You'll notice it looks right in the dropdown text... but not right once it's been selected.Code:Ext.exampledata.states = [ ['AL', 'Alabama & test'], ['AK', 'Alaska'], ['AZ', 'Arizona'] ]
-
29 Aug 2007 12:45 PM #5
What should then be shown for ['AL', 'Alabama & test']? & or & ?
Jozef Sakalos, aka Saki
A lot of valuable info at:
Saki's Extensions and Plugins
Saki's Extensions and Plugins Docs
Saki's Examples, Latest: Grid in Card Layout
Saki's Blog, Featured: Writing a Big Application in Ext, Latest: Grid MultiSearch Plugin Video
-
29 Aug 2007 3:14 PM #6
I'd expect to see Alabama & test, which is what we would post back to the server and would stick in the database.
Reason for needing to htmlEncode the strings is that a user might enter <h1>Alabama</h1> into a text field, and we'll save it to the database. When it comes out, it needs to not mess with the html of the page.
If we don't htmlEncode it, then inside the Ext combo box, that "option" will have a real H1 stuck into it, which will mess up the display.
Ideally we would have a new option for Ext.form.ComboBox that will unHtmlEncode before setting the value of the textbox. That way people expecting the current behavior won't have any problems.
unHtmlEncode() has been mixed into String in prototype.js, though I don't see a similar function in Ext.
If that method existed, could do something like:
If you don't think this is useful for everyone, we can roll that solution for ourselves, but htmlEncoding data that a customer might edit is a normally a "good thing".Code:setValue : function(v){ var text = v; if(this.valueField){ var r = this.findRecord(this.valueField, v); if(r){ text = r.data[this.displayField]; }else if(this.valueNotFoundText !== undefined){ text = this.valueNotFoundText; } } this.lastSelectionText = text; if(this.hiddenField){ this.hiddenField.value = v; } // new code here if (this.unEscapeValue) { text = text.unescapeHTML(); } Ext.form.ComboBox.superclass.setValue.call(this, text); this.value = v; },
-
29 Aug 2007 7:10 PM #7
values in an Ext.data.Record should always be the actual value pulled from / going into the backend database i.e. 'Alabama & test', and not the htmlEncode-ed value used for display i.e. 'Alabama & test'.
once this is straightened out, all that is needed is to correctly handle html entities when displaying data. in the case of the ComboBox, all you'll need is an Ext.Template like so:
http://extjs.com/forum/showthread.php?t=11113
Sencha Docs / Ext 3.x - ( Docs | Examples )
Learning Center / Saki's Examples (for 2.x) / HOWTO - ( Report Bugs | Post Proper Code )
-
11 Feb 2008 6:49 AM #8
ComboBox component can cause XSS
ComboBox component can cause XSS
ComboBox component can cause XSS.
Try example from examples direcotory examples/form/combos.html and in file states.js change code to:
Than run this example in Firefox and expand the list of ComboBox. Javascript alert with test "XSS" appears (XSS vulnerability).Code:Ext.exampledata.states = [ ['AL', 'Alabama <b>bold</b><img scr=xss onerror=alert("xss")>', 'The Heart of Dixie'], ...
Also ComboBox list and ComboBox selected value is not consistent when some evil characters are in data. How can I solve this?
-
11 Feb 2008 7:28 AM #9
this has been discussed many times before.
as mentioned 1 post up:
http://extjs.com/forum/showthread.php?t=11113
try that.
[edit]
and these too:
http://www.google.com/cse?cx=0116939...utf-8&oe=utf-8
Sencha Docs / Ext 3.x - ( Docs | Examples )
Learning Center / Saki's Examples (for 2.x) / HOWTO - ( Report Bugs | Post Proper Code )
-
11 Feb 2008 10:36 PM #10


Reply With Quote