Changeset 13340

Show
Ignore:
Timestamp:
04/16/08 15:57:44 (7 months ago)
Author:
wolfram
Message:

+ encode HTML entities properly, so they at least dont screw up the markup fixes#6461

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • dijit/trunk/form/ComboBox.js

    r13300 r13340  
    649649                        //              highlights the first occurence found. Override this method 
    650650                        //              to implement your custom highlighing. 
    651                         var rx = new RegExp("("+this._lastInput+")", "i"); 
    652                         return label.replace(rx, '<span class="dijitComboBoxHighlightMatch">$1</span>'); 
     651                        var pos = label.toLowerCase().indexOf(this._lastInput.toLowerCase()); 
     652                        if (pos!=-1) { 
     653                                var l = this._lastInput.length; 
     654                                var e = this._escapeHtml; 
     655                                return e(label.substr(0, pos)) + '<span class="dijitComboBoxHighlightMatch">' + 
     656                                                e(label.substr(pos, l)) + '</span>' + e(label.substr(pos+l)); 
     657                        } 
     658                        return label; 
     659                }, 
     660                 
     661                _escapeHtml:function(/*string*/str){ 
     662                        // TODO Should become dojo.html.entities(), when exists use instead 
     663                        // summary: 
     664                        //              Adds escape sequences for special characters in XML: &<>"' 
     665                        str = String(str).replace(/&/gm, "&amp;").replace(/</gm, "&lt;") 
     666                                .replace(/>/gm, "&gt;").replace(/"/gm, "&quot;"); 
     667                        return str; // string 
    653668                }, 
    654669