Skip to content

Conversation

@CreatorHead
Copy link
Contributor

@CreatorHead CreatorHead commented Feb 5, 2026

🛠️ Description

This PR fixes a critical bug where JavaScript code was being incorrectly identified and modified as copyright headers, corrupting the code. The issue occurred because the copyright detection logic used a generic " " (two spaces) prefix that matched any indented content containing the word "copyright" across all file types.

What changed:

  • Removed " " from the global commentPrefixes array to prevent false positives
  • Introduced file-aware copyright detection with getCommentPrefixesForFile() that returns context-appropriate prefixes based on file type and location within the file
  • Added comment block state tracking in extractAllCopyrightInfo() to detect {{! ... }} boundaries in .hbs files
  • Created hbsIndentedPrefixes array (containing " " and "\t") that only applies inside .hbs comment blocks
  • Updated parseCopyrightLine() to accept inHbsCommentBlock parameter for context-aware parsing
  • Updated all tests to include filePath and inHbsCommentBlock fields

Why:
The previous implementation treated any indented line containing "copyright" as a copyright header, regardless of file type or context. This caused JavaScript code like copyright: 'Copyright xyz Inc.' in .hbs files to be incorrectly modified. The new file-aware approach ensures that indented copyright detection only applies within actual comment blocks in .hbs files, leaving embedded code untouched.

Impact:

  • .hbs files: Copyright headers inside {{! ... }} comment blocks are correctly detected and updated
  • .hbs files: JavaScript code in <script> tags is no longer touched
  • Other file types (.js, .go, .py, etc.): No behavior change - continue to work as before
  • Tested against boundary-ui repository to validate real-world usage

🔗 External Links

N/A

👍 Definition of Done

  • New functionality works? - Verified on boundary-ui repository
  • Tests added? - Updated existing tests with new parameters and verified all tests pass

🤔 Can be merged upon approval?

PCI review checklist

  • I have documented a clear reason for, and description of, the change I am making.

  • If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request. - Simple revert of PR will restore previous behavior

  • If applicable, I've documented the impact of any changes to security controls. - No changes to security controls; this is a bug fix for copyright header detection logic

@CreatorHead CreatorHead requested a review from a team as a code owner February 5, 2026 14:30
- Remove generic '  ' prefix from commentPrefixes to prevent false positives
- Add getCommentPrefixesForFile() for file-type-aware prefix detection
- Track {{! ... }} comment block state for .hbs files
- Only apply indented prefix detection inside {{! }} blocks
- Prevents JavaScript code in <script> tags from being modified
- Updates tests to pass inHbsCommentBlock parameter
@CreatorHead CreatorHead force-pushed the fix-hbs-copyright-parsing branch from 57161ff to 87cd945 Compare February 5, 2026 14:44
Copy link
Collaborator

@mohanmanikanta2299 mohanmanikanta2299 left a comment

Choose a reason for hiding this comment

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

LGTM

@CreatorHead CreatorHead merged commit 0be59e7 into main Feb 6, 2026
5 checks passed
@CreatorHead CreatorHead deleted the fix-hbs-copyright-parsing branch February 6, 2026 08:08
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