microsoft / roosterjs

roosterjs is a framework-independent javascript rich text editor.
Other
1.17k stars 157 forks source link

js/incorrect-suffix-check - Using indexOf to implement endsWith functionality is error-prone if the -1 case is not explicitly handled. #2771

Closed sswathisri closed 3 weeks ago

sswathisri commented 1 month ago

Hello,

We have a Code QL bug reported in this library for js/incorrect-suffix-check Error: Using indexOf to implement endsWith functionality is error-prone if the -1 case is not explicitly handled. Severity: High and Important

FIle is under \roosterjs-editor-dom\lib-mjs\utils\getComputedStyles.js. Screenshot shows the function and line to add check.

Expected behavior Suggested fix: if (px && px.indexOf('px') !== -1 && px.indexOf('px') == px.length - 2) {

Screenshots image

Device Information N/A

Additional context N/A

Please kindly address this issue as soon as possible. Thank you.

JiuqingSong commented 3 weeks ago

The v8 code (roosterjs-editor-*) is not deprecated and we will not fix more bugs for it. Please use v9 instead.