chore: renderTextByKeyword过滤掉非法输入 (#7319)

This commit is contained in:
RUNZE LU 2023-06-30 14:46:56 +08:00 committed by GitHub
parent 340bb31d73
commit a4aaac2d19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -279,6 +279,10 @@ export function getStyleNumber(element: HTMLElement, styleName: string) {
/** 根据关键字高亮显示文本内容 */
export function renderTextByKeyword(rendererText: string, curKeyword: string) {
if (!rendererText || typeof rendererText !== 'string') {
return rendererText;
}
if (curKeyword && ~rendererText.indexOf(curKeyword)) {
const keywordStartIndex = rendererText.indexOf(curKeyword);
const keywordEndIndex = keywordStartIndex + curKeyword.length;