From 46ae42ce10e4b241b96f296a9e6b1b601e787f7c Mon Sep 17 00:00:00 2001 From: "smit.codes" Date: Mon, 8 Jun 2026 10:30:27 +0300 Subject: [PATCH] appview/markup: restrict README candidate matching Restricts README detection to `README` or `README.` filenames only, preventing files like `README.Music.md` being selected to be rendered over `README.md` Fixes [#604](https://tangled.org/tangled.org/core/issues/604) Signed-off-by: Smit Patil --- appview/pages/markup/format.go | 2 +- appview/pages/markup/format_test.go | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/appview/pages/markup/format.go b/appview/pages/markup/format.go index e403f787..f4c87d8f 100644 --- a/appview/pages/markup/format.go +++ b/appview/pages/markup/format.go @@ -17,7 +17,7 @@ var FileTypePatterns = map[Format]*regexp.Regexp{ FormatMarkdown: regexp.MustCompile(`(?i)\.(md|markdown|mdown|mkdn|mkd)$`), } -var ReadmePattern = regexp.MustCompile(`(?i)^readme(?:[._-].+)?$`) +var ReadmePattern = regexp.MustCompile(`(?i)^readme(?:\.[^.]+)?$`) // IsReadmeFile reports whether name/mode identifies a readme blob. The git // mode is checked so directories or symlinks named "readme" are filtered out. diff --git a/appview/pages/markup/format_test.go b/appview/pages/markup/format_test.go index c2881b84..b04ad01a 100644 --- a/appview/pages/markup/format_test.go +++ b/appview/pages/markup/format_test.go @@ -30,13 +30,16 @@ func TestIsReadmeFile(t *testing.T) { {"readme", dirMode, false}, {"README.md", dirMode, false}, - // readme is matched by convention, not by renderable format — + // readme is matched by convention, not by renderable format; // unsupported markup falls through to plaintext in GetFormat. {"README.rst", fileMode, true}, {"README.org", fileMode, true}, - {"readme-old", fileMode, true}, - {"readme_legacy", fileMode, true}, + {"README.asciidoc", fileMode, true}, + {"README.foo", fileMode, true}, + {"README.Music.md", fileMode, false}, + {"readme-old", fileMode, false}, + {"readme_legacy", fileMode, false}, {"notreadme.md", fileMode, false}, {"READMEISH", fileMode, false}, {"README.md", "", false}, -- 2.51.2