@@ -75,5 +75,55 @@ describe("Text normalization utilities", () => {
7575 expect ( unescapeHtmlEntities ( "" ) ) . toBe ( "" )
7676 expect ( unescapeHtmlEntities ( undefined as unknown as string ) ) . toBe ( undefined )
7777 } )
78+
79+ // Issue #4077 - HTML entity handling verification
80+ it ( "should demonstrate that unescapeHtmlEntities converts & to &" , ( ) => {
81+ const input = "// Step 5 & 6: Verify the data"
82+ const result = unescapeHtmlEntities ( input )
83+
84+ expect ( result ) . toBe ( "// Step 5 & 6: Verify the data" )
85+ expect ( result ) . not . toBe ( input )
86+ expect ( result ) . not . toContain ( "&" )
87+ expect ( result ) . toContain ( "&" )
88+ } )
89+
90+ it ( "should show the exact problem from issue #4077" , ( ) => {
91+ // The user's SEARCH block content (what they see in their file)
92+ const searchContent = "// Adım 5 & 6: İşaret edilen verinin bölümünü bul ve doğrula"
93+
94+ // After unescaping (what happens for non-Claude models)
95+ const unescapedSearch = unescapeHtmlEntities ( searchContent )
96+
97+ // The actual file content (contains HTML entity)
98+ const fileContent = "// Adım 5 & 6: İşaret edilen verinin bölümünü bul ve doğrula"
99+
100+ // This demonstrates the mismatch
101+ expect ( unescapedSearch ) . toBe ( "// Adım 5 & 6: İşaret edilen verinin bölümünü bul ve doğrula" )
102+ expect ( unescapedSearch ) . not . toBe ( fileContent )
103+
104+ // The key issue: when searching for the unescaped version in the file content
105+ // it won't find a match because the file has & but we're searching for &
106+ const willFindMatch = fileContent . includes ( unescapedSearch )
107+ expect ( willFindMatch ) . toBe ( false )
108+
109+ // But if we search for the original (not unescaped), it would work
110+ const wouldFindMatchWithoutUnescape = fileContent . includes ( searchContent )
111+ expect ( wouldFindMatchWithoutUnescape ) . toBe ( true )
112+ } )
113+
114+ it ( "should verify all HTML entities are unescaped" , ( ) => {
115+ const testCases = [
116+ { input : "<" , expected : "<" } ,
117+ { input : ">" , expected : ">" } ,
118+ { input : """ , expected : '"' } ,
119+ { input : "'" , expected : "'" } ,
120+ { input : "'" , expected : "'" } ,
121+ { input : "&" , expected : "&" } ,
122+ ]
123+
124+ testCases . forEach ( ( { input, expected } ) => {
125+ expect ( unescapeHtmlEntities ( input ) ) . toBe ( expected )
126+ } )
127+ } )
78128 } )
79129} )
0 commit comments