mirror of
https://github.com/zotero/zotero.git
synced 2026-09-16 23:41:08 +00:00
Remove ascii control chars from rendered item title (#4764)
Filter out ASCII control characters in renderItemTitle, since an error is thrown if those characters are present when the innerHTML of a tab name in tab bar is set via dangerouslySetInnerHTML. Fixes: #4758 --------- Co-authored-by: Dan Stillman <dstillman@zotero.org>
This commit is contained in:
parent
4c68f834c1
commit
1df2a96ae3
1 changed files with 6 additions and 0 deletions
|
|
@ -2431,6 +2431,12 @@ Zotero.Utilities.Internal = {
|
|||
let nodeStack = targetNode ? [targetNode] : null;
|
||||
let textContent = '';
|
||||
|
||||
// Inserting text with ASCII control character as innerHTML (e.g., in tabBar.jsx) can cause
|
||||
// an error, so filter out control characters 0-31 and character 127 DEL
|
||||
//
|
||||
// https://forums.zotero.org/discussion/118779/special-characters-in-item-title-breaks-the-tab-bar
|
||||
title = title.replace(/[\x00-\x1F\x7F]/g, '');
|
||||
|
||||
for (let token of title.split(/(<[^>]+>)/)) {
|
||||
if (this._titleMarkup.hasOwnProperty(token)) {
|
||||
let markup = this._titleMarkup[token];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue