JiHong88 / suneditor

Pure javascript based WYSIWYG html editor, with no dependencies.
http://suneditor.com
MIT License
1.67k stars 308 forks source link

Link URL is not escaped when searching for matching protocol #1327

Closed Danielfelgate closed 7 months ago

Danielfelgate commented 8 months ago

Describe the bug When a linkProtocol is specified in options, it seems to search the url using regex to determine if the url's protocol matches the linkProtocol option. However the url is not escaped, resulting in a SyntaxError if any regex special characters are present in the link.

To Reproduce Steps to reproduce the behavior:

Go to http://suneditor.com/sample/html/options.html Enable linkProtocol and set to anything e.g. https:// Select 'Create' to generate the editor Open add link dialogue Type a regex special character such as '[' in the URL to link input

Screenshots image

Desktop OS: macOS 13.5 Browser: Chrome Version: 118.0.5993.117 (Official Build) (x86_64)