mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-08-03 19:38:36 -04:00
Workaround for rogue HTML entities in dirEntry titles
See https://github.com/openzim/mwoffliner/issues/1797
This commit is contained in:
parent
e422da0e06
commit
b76550dcd8
@ -4860,8 +4860,12 @@ function populateListOfArticles (dirEntryArray, reportingSearch) {
|
||||
// inside double quotes (in the final HTML string), given that dirEntryStringId may contain bare apostrophes
|
||||
// Info: encodeURIComponent encodes all characters except A-Z a-z 0-9 - _ . ! ~ * ' ( )
|
||||
var dirEntryStringId = encodeURIComponent(dirEntry.toStringId());
|
||||
// DEV: Some titles may contain malformed HTML characters like '<i>' for '<i>', so we transform only bold and italics for display
|
||||
// @TODO: Remove when [openzim/mwoffliner #1797] is fixed
|
||||
var dirEntryTitle = dirEntry.getTitleOrUrl();
|
||||
dirEntryTitle = dirEntryTitle.replace(/<([ib])>([^&]+)<\/\1>/g, '<$1>$2</$1>');
|
||||
articleListDivHtml += '<a href="#" dirEntryId="' + dirEntryStringId +
|
||||
'" class="list-group-item">' + (reportingSearch.searchUrlIndex ? dirEntry.namespace + '/' + dirEntry.url : '' + dirEntry.getTitleOrUrl()) + '</a>';
|
||||
'" class="list-group-item">' + (reportingSearch.searchUrlIndex ? dirEntry.namespace + '/' + dirEntry.url : '' + dirEntryTitle) + '</a>';
|
||||
}
|
||||
articleListDiv.innerHTML = articleListDivHtml;
|
||||
// We have to use mousedown below instead of click as otherwise the prefix blur event fires first
|
||||
|
@ -43,7 +43,6 @@ function DirEntry (zimfile, dirEntryData) {
|
||||
* @returns {String}
|
||||
*/
|
||||
DirEntry.prototype.toStringId = function () {
|
||||
// @todo also store isRedirect and redirectTarget
|
||||
return this.offset + '|' + this.mimetypeInteger + '|' + this.namespace + '|' + this.cluster + '|' +
|
||||
this.blob + '|' + this.url + '|' + this.title + '|' + this.redirect + '|' + this.redirectTarget;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user