package web import ( "strings" "testing" ) func TestAModelCardCannotRunOrLoadAnything(t *testing.T) { card := "# Qwen\n\nA **small** model.\n\n\n\n" + "\n\n[click](javascript:alert(1))\n\n" + "![benchmark](https://tracker.example/pixel.png)\n\n[license](LICENSE)\n\n" + "| a | b |\n|---|---|\n| 1 | 2 |\n" got := string(renderCard(card, "https://huggingface.co/Qwen/X/blob/abc/")) for _, bad := range []string{"[benchmark]`) { t.Errorf("an image should become a link: %s", got) } if !strings.Contains(got, `href="https://huggingface.co/Qwen/X/blob/abc/LICENSE"`) { t.Errorf("a relative link should point into the repository: %s", got) } if !strings.Contains(got, "small") || !strings.Contains(got, "") { t.Errorf("the markdown should render, tables included: %s", got) } }