Permalink
Browse files

corrected _decodeHTMLEntities

  • Loading branch information...
fb55 committed Aug 26, 2011
1 parent 0a07e99 commit 125c478c6b197e849eb771312b03946da30f9a55
Showing with 3 additions and 9 deletions.
  1. +3 −9 lib/nodepie.js
View
@@ -107,15 +107,9 @@ NodePie.HTMLEntities = {
* Decodes any HTML entities in a string into their unicode form
**/
NodePie._decodeHTMLEntities = function(text){
- return text.replace(/&#(\d{2,4});/g, function(o, nr){
- if(nr!="173"){ // keep ­
- return String.fromCharCode(nr);
- }else{
- return o;
- }
- }).replace(/&([a-zA-Z]+([0-9]+)?);/g, function(o, code){
- return NodePie.HTMLEntities[code] || o;
- });
+ return text.replace(/&(.+?);/g, function(str, ent){
+ return String.fromCharCode( ent[0]!='#' ? entityToCode[ent] : ent[1]=='x' ? parseInt(ent.substr(2),16): parseInt(ent.substr(1)) )}
+ );
};
/**

0 comments on commit 125c478

Please sign in to comment.