fix: escape html to get tooltip text (#167)
This commit is contained in:
parent
f990c1ff87
commit
6c79a19b29
@ -2,7 +2,8 @@ import {
|
||||
copyTextToClipboard,
|
||||
makeDataAttributeString,
|
||||
throttle,
|
||||
linkProperties
|
||||
linkProperties,
|
||||
escapeHTML,
|
||||
} from './utils';
|
||||
import $ from './dom';
|
||||
import icons from './icons';
|
||||
@ -886,7 +887,7 @@ export default class CellManager {
|
||||
let textContent = div.textContent;
|
||||
textContent = textContent.replace(/\s+/g, ' ').trim();
|
||||
|
||||
cellContentHTML = cellContentHTML.replace('>', ` title="${textContent}">`);
|
||||
cellContentHTML = cellContentHTML.replace('>', ` title="${escapeHTML(textContent)}">`);
|
||||
|
||||
return cellContentHTML;
|
||||
}
|
||||
|
||||
16
src/utils.js
16
src/utils.js
@ -149,3 +149,19 @@ export function format(str, args) {
|
||||
|
||||
return str;
|
||||
};
|
||||
|
||||
export function escapeHTML(txt) {
|
||||
if (!txt) return '';
|
||||
let escapeHtmlMapping = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
"'": ''',
|
||||
'/': '/',
|
||||
'`': '`',
|
||||
'=': '=',
|
||||
};
|
||||
|
||||
return String(txt).replace(/[&<>"'`=/]/g, (char) => escapeHtmlMapping[char] || char);
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user