Skip to content
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ _This release is scheduled to be released on 2023-07-01._
- Use node v19 in github workflow (replacing v14)
- Refactor formatTime into common util function for default modules
- Refactor some calendar methods into own class and added tests for them
- Properly convert newsfeed titles

### Fixed

Expand Down
11 changes: 11 additions & 0 deletions modules/default/newsfeed/newsfeed.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ Module.register("newsfeed", {
return true;
}, this);
}

// HTML entity conversion: dummy textarea for conversion and regex for safe matching
const entity_regex = /&(?:#x[a-f0-9]+|#[0-9]+|[a-z0-9]+);?/gi;
const entity_converter = document.createElement("textarea");

newsItems.forEach((item) => {
//Remove selected tags from the beginning of rss feed items (title or description)
if (this.config.removeStartTags === "title" || this.config.removeStartTags === "both") {
Expand Down Expand Up @@ -251,6 +256,12 @@ Module.register("newsfeed", {
}
}
}

//Convert HTML entities to characters
item.title = item.title.replace(entity_regex, (t) => {
entity_converter.innerHTML = t;
return entity_converter.textContent;
});
});

// get updated news items and broadcast them
Expand Down