Skip to content

fix: resolve lines.indexOf bug and safe string replacement pattern bugs in scripts#139

Merged
shinpr merged 1 commit into
shinpr:mainfrom
MatrixNeoKozak:fix/improvement-1782322025941
Jun 24, 2026
Merged

fix: resolve lines.indexOf bug and safe string replacement pattern bugs in scripts#139
shinpr merged 1 commit into
shinpr:mainfrom
MatrixNeoKozak:fix/improvement-1782322025941

Conversation

@MatrixNeoKozak

Copy link
Copy Markdown
Contributor

This change fixes two critical bugs in the project's helper scripts:

  1. In scripts/check-skills-index.mjs, the method parseSkillsIndex previously utilized lines.indexOf(line) to obtain the line number of the skill entry in the skills-index.yaml file. If there were identical lines in the file (such as identical formatting, sections, or comments), indexOf would yield the index of the first occurrence instead of the active loop index. This is resolved by iterating over lines using a standard index-based loop and computing the line number directly from the loop variable index.

  2. In scripts/sync-plugins.mjs, the method injectDeprecationNotice used string replacement with dynamic arguments (notice, currentDesc, and newFm). Because JS String.prototype.replace treats $ as a special replacement pattern prefix (e.g., matching $& to duplicate the match), any occurrence of $ in the description or deprecation notice would be improperly parsed and expand to arbitrary matched substrings. This is corrected by supplying replacement callback functions to the replace calls, preventing pattern expansion bugs.

@shinpr shinpr self-requested a review June 24, 2026 22:10

@shinpr shinpr left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix. Both look correct, merging.

@shinpr shinpr merged commit 7214dfc into shinpr:main Jun 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants