@@ -4,13 +4,14 @@ function html_entity_decode( string ) {
44 // + input by: ger
55 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
66 // + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
7+ // + bugfixed by: Onno Marsman
78 // % note: table from http://www.the-art-of-web.com/html/character-codes/
89 // * example 1: html_entity_decode('Kevin & van Zonneveld');
910 // * returns 1: 'Kevin & van Zonneveld'
10-
11+
1112 var histogram = { } , histogram_r = { } , code = 0 ;
1213 var entity = chr = '' ;
13-
14+
1415 histogram [ '34' ] = 'quot' ;
1516 histogram [ '38' ] = 'amp' ;
1617 histogram [ '60' ] = 'lt' ;
@@ -111,19 +112,19 @@ function html_entity_decode( string ) {
111112 histogram [ '253' ] = 'yacute' ;
112113 histogram [ '254' ] = 'thorn' ;
113114 histogram [ '255' ] = 'yuml' ;
114-
115- // Reverse table. Cause for maintainability purposes, the histogram is
115+
116+ // Reverse table. Cause for maintainability purposes, the histogram is
116117 // identical to the one in htmlentities.
117118 for ( code in histogram ) {
118119 entity = histogram [ code ] ;
119- histogram_r [ entity ] = code ;
120+ histogram_r [ entity ] = code ;
120121 }
121-
122- return string . replace ( / ( \& ( [ a - z A - Z ] + ) \; ) / g, function ( full , m1 , m2 ) {
122+
123+ return ( string + '' ) . replace ( / ( \& ( [ a - z A - Z ] + ) \; ) / g, function ( full , m1 , m2 ) {
123124 if ( m2 in histogram_r ) {
124125 return String . fromCharCode ( histogram_r [ m2 ] ) ;
125126 } else {
126127 return m2 ;
127128 }
128- } ) ;
129+ } ) ;
129130}
0 commit comments