BUG 6913 Suggest fied problem with characteres like #, $ and & is solved

This commit is contained in:
Erik Amaru Ortiz
2011-05-19 10:58:55 -04:00
parent c2c0414702
commit c218dad390
4 changed files with 39 additions and 7 deletions

View File

@@ -471,7 +471,12 @@ _b.AutoSuggest.prototype.setHighlightedValue = function ()
{
if (this.iHigh)
{
this.sInp = this.fld.value = this.aSug[ this.iHigh-1 ].value;
/**
* @autor Erik Amaru Ortiz <erik@colosa.com>
* This fix when a item on suggestion list have html wntities sent by json like &amp;
*/
this.sInp = this.fld.value = html_entity_decode(this.aSug[ this.iHigh-1 ].value);;
//
// move cursor to end of input (safari)
//
@@ -493,7 +498,7 @@ _b.AutoSuggest.prototype.setHighlightedValue2 = function ()
{
if (this.iHigh)
{
this.sInp = this.fld.value = this.aSug[ this.iHigh-1 ].value;
this.sInp = this.fld.value = html_entity_decode(this.aSug[ this.iHigh-1 ].value);
// move cursor to end of input (safari)
//
@@ -772,4 +777,24 @@ function storeEntry(o, cnn, table, pk, pkt, fld){
//alert(req)
} );
}
}
}
function html_entity_decode( string, quote_style ) {
var histogram = {}, symbol = '', tmp_str = '', entity = '';
tmp_str = string.toString();
if (false === (histogram = get_html_translation_table('HTML_ENTITIES', quote_style))) {
return false;
}
// &amp; must be the last character when decoding!
delete(histogram['&']);
histogram['&'] = '&amp;';
for (symbol in histogram) {
entity = histogram[symbol];
tmp_str = tmp_str.split(entity).join(symbol);
}
return tmp_str;
}