mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-05 08:10:14 +00:00
3.2 KiB
3.2 KiB
Description
Fixes #5633
This PR resolves the critical HTML entity escaping/unescaping issue that was causing diff search/replace operations to fail or produce unintended content modifications.
Problem
The apply_diff tools were unescaping HTML entities (e.g., & → &) in search content for non-Claude models, but the actual file content still contained the escaped entities. This caused:
- Search failures: When LLMs provided search content with HTML entities, the unescaping made it not match the actual file content
- Unintended modifications: Partial matches could lead to incorrect replacements in files
Solution
- Removed HTML entity unescaping logic from applyDiffTool.ts and multiApplyDiffTool.ts for non-Claude models
- Preserved HTML entities in search content to ensure exact matching with file content
- Removed unused imports of unescapeHtmlEntities from both files
- Added comprehensive test coverage to prevent regression
Changes Made
-
src/core/tools/applyDiffTool.ts:
- Removed HTML entity unescaping for non-Claude models (lines 26-28)
- Removed unused import of unescapeHtmlEntities (line 13)
-
src/core/tools/multiApplyDiffTool.ts:
- Replaced HTML entity unescaping logic with simple assignment (lines 414-418)
- Removed unused import of unescapeHtmlEntities (line 13)
-
src/core/tools/tests/applyDiffHtmlEntity.spec.ts:
- Added comprehensive test suite with 5 test cases
- Tests verify HTML entities are preserved in search/replace operations
- Tests cover various entity types: &, <, >, ', "
- Tests verify both Claude and non-Claude model behavior
Testing
- All existing tests pass
- Added comprehensive tests for HTML entity handling scenarios:
- HTML entities preserved in search content for non-Claude models
- HTML entities still unescaped for Claude models (backward compatibility)
- Various entity types tested (&, <, >, ', ")
- Both single and multiple entity scenarios covered
- Manual testing completed:
- Verified search operations work with HTML entities in content
- Confirmed no unintended content modifications occur
- All linting and type checking passes
Verification of Acceptance Criteria
- Search failures resolved: HTML entities in search content now match file content exactly
- Unintended modifications prevented: No more partial matches causing incorrect replacements
- Backward compatibility maintained: Claude model behavior unchanged
- No regressions: All existing functionality preserved
- Comprehensive test coverage: Edge cases and scenarios covered
Related Issues
This issue was previously attempted to be fixed in:
- PR #5608 (closed without merging)
- Issue #4077 (related HTML entity handling)
This PR provides a complete and tested solution that addresses the root cause.
Checklist
- Code follows project style guidelines
- Self-review completed
- Comments added for complex logic
- Documentation updated (test documentation)
- No breaking changes
- All tests passing
- Linting and type checking passes