Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions html-substring.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,18 @@ function html_substr(src, length, suffix){
tagTree.push(tagStrip(tag));
}
i = end; //Move the position to end of the tag

} else if (c == '&') {
// HTML Character Entities found - https://www.w3schools.com/HTML/html_entities.asp
end = src.slice(i).indexOf(";");
if(end == -1) { //Check for incomplete entity name
return str;
}
end += i + 1;
tag = src.slice(i,end); //Read entity name
// Append entity name and move the position
str += tag; //Append the entity name to final content
i = end; // Move the position to end of the entity name
cnt++;
} else {
//Append content character and move the position
str += c;
Expand All @@ -69,4 +80,4 @@ function html_substr(src, length, suffix){
}
if (module && module.exports) {
module.exports = html_substr;
}
}