Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

新组件[Highlight]的patterns含有空字符串会导致无响应 #6405

Open
5 tasks done
dongchengjie opened this issue Sep 27, 2024 · 0 comments
Open
5 tasks done
Labels
untriaged need to sort

Comments

@dongchengjie
Copy link

dongchengjie commented Sep 27, 2024

描述错误

v2.40.0新引入的高亮组件Highlight,如果参数patterns传入的数组中含有长度为0的字符串,则会正则匹配卡住(疯狂消耗CPU),导致页面无响应

这时候就得手动array.filter(Boolean)过滤掉了,有点麻烦。这块地方应该组件内处理一下吧,如果发现空串就是不进行高亮操作,直接忽略。

复现步骤

访问复现链接,将Demo.vue文件中patterns数组中任意一个长度不为0的字符串修改为长度为0的字符串,程序卡住无响应

最小复现链接

https://codesandbox.io/p/sandbox/8pjg29

系统信息

System:
    OS: Windows 10 10.0.19043
    CPU: (16) x64 AMD Ryzen 7 5800H with Radeon Graphics
    Memory: 7.32 GB / 15.86 GB
  Binaries:
    Node: 20.15.0 - D:\nodejs\node.EXE
    npm: 10.8.3 - D:\nodejs\npm.CMD
    pnpm: 9.10.0 - ~\AppData\Local\pnpm\pnpm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (127.0.2651.74)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    naive-ui: ^2.40.1 => 2.40.1
    vue: ^3.5.10 => 3.5.10

使用的包管理器

pnpm

验证

@dongchengjie dongchengjie added the untriaged need to sort label Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
untriaged need to sort
Projects
None yet
Development

No branches or pull requests

1 participant