@@ -399,6 +399,44 @@ func TestWebFetchHTMLRenderingHonorsDetailsAndDialogVisibility(t *testing.T) {
399399 }
400400}
401401
402+ func TestWebFetchHTMLRenderingSkipsIframeFallbackContent (t * testing.T ) {
403+ server := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
404+ w .Header ().Set ("Content-Type" , "text/html; charset=utf-8" )
405+ _ , _ = w .Write ([]byte (`<!doctype html>
406+ <html>
407+ <body>
408+ <main>
409+ <iframe src="/embedded">
410+ <p>Hidden iframe pricing leak should not render.</p>
411+ </iframe>
412+ <p>Visible iframe pricing guidance appears in the page body.</p>
413+ </main>
414+ </body>
415+ </html>` ))
416+ }))
417+ defer server .Close ()
418+ executor := webExecutor (t )
419+ result , err := executor .Execute (tool.Context {Context : context .Background (), Metadata : map [string ]any {}}, contracts.ToolUse {
420+ ID : "toolu_web_html_iframe" ,
421+ Name : "WebFetch" ,
422+ Input : json .RawMessage (`{"url":` + strconvQuote (server .URL ) + `,"prompt":"iframe pricing"}` ),
423+ }, nil )
424+ if err != nil {
425+ t .Fatal (err )
426+ }
427+ rendered , ok := result .StructuredContent ["rendered_body" ].(string )
428+ if ! ok || ! strings .Contains (rendered , "Visible iframe pricing guidance" ) {
429+ t .Fatalf ("rendered body = %#v" , result .StructuredContent ["rendered_body" ])
430+ }
431+ if strings .Contains (rendered , "Hidden iframe pricing leak" ) {
432+ t .Fatalf ("rendered body leaked iframe fallback text: %#v" , rendered )
433+ }
434+ excerpt , ok := result .StructuredContent ["prompt_excerpt" ].(string )
435+ if ! ok || ! strings .Contains (excerpt , "Visible iframe pricing guidance" ) || strings .Contains (excerpt , "Hidden iframe pricing leak" ) {
436+ t .Fatalf ("prompt excerpt = %#v" , result .StructuredContent ["prompt_excerpt" ])
437+ }
438+ }
439+
402440func TestWebFetchHTMLRenderingPreservesLinksAndImageText (t * testing.T ) {
403441 server := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
404442 w .Header ().Set ("Content-Type" , "text/html; charset=utf-8" )
0 commit comments