Skip to content

Conversation

@nathanlesage
Copy link
Contributor

@nathanlesage nathanlesage commented Feb 8, 2026

Small thing I just noted when I went to prepare a new plugin for release: The Winter CMS backend doesn't check the filenames "LICENSE" and "LICENCE" when providing plugin details. This PR adds them.

(I didn't check how common these are, but I have seen quite a bit of repositories — including my own — that omit the filename extension.)

Nota bene: We might want to also refactor the Markdown-parsing step since extensionless files usually are supposed to be rendered as plain text. That is less of an issue, though, but if you're up to it, I can draft up another PR quickly.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced license file detection to recognize additional naming variations, improving system compatibility with diverse project structures.

This adds common License file names (which usually don't come with extensions) to the list of searchable files.
@coderabbitai
Copy link

coderabbitai bot commented Feb 8, 2026

Walkthrough

The license file lookup functionality in the Updates controller is extended to recognize license files without file extensions. Two additional filename candidates ('LICENCE' and 'LICENSE') are added to the existing search array.

Changes

Cohort / File(s) Summary
License File Lookup
modules/system/controllers/Updates.php
Extended the $licenceFiles array in Updates::details() method to include bare license filenames ('LICENCE', 'LICENSE') in addition to existing candidates with extensions ('LICENCE.md', 'licence.md', 'LICENSE.md', 'license.md').

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding common license filenames (without extensions) to the license file lookup.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
modules/system/controllers/Updates.php (1)

181-200: ⚠️ Potential issue | 🟡 Minor

getPluginMarkdownFile applies Markdown parsing to all files regardless of extension.

When this method processes the newly added extensionless LICENCE/LICENSE files (which are typically plain text), Markdown::parse() on line 194 may produce garbled HTML output. A minimal guard could skip Markdown parsing for files without a .md extension:

Sketch of a conditional parse
             $contents = File::get($path . '/'.$file);

-            /*
-             * Parse markdown, clean HTML, remove first H1 tag
-             */
-            $contents = Markdown::parse($contents);
+            if (pathinfo($file, PATHINFO_EXTENSION) === 'md') {
+                $contents = Markdown::parse($contents);
+            } else {
+                $contents = '<pre>' . e($contents) . '</pre>';
+            }
             $contents = Html::clean($contents);
             $contents = preg_replace('@<h1[^>]*?>.*?<\/h1>@si', '', $contents, 1);

This would prevent plain-text license files from being misinterpreted as Markdown. Given the PR author plans a follow-up for this, consider addressing it now or as an immediate next step.

🧹 Nitpick comments (1)
modules/system/controllers/Updates.php (1)

130-130: Consider adding .txt variants and note the Markdown-parsing concern.

Common license filenames also include LICENSE.txt, LICENCE.txt, and their lowercase variants. You may want to add those for completeness.

More importantly, extensionless (and .txt) license files are plain text, but getPluginMarkdownFile() on line 194 unconditionally runs Markdown::parse() on the contents. This can mangle plain-text formatting (e.g., lines with *, _, or indentation being reinterpreted). I see from the PR description you're aware of this and plan a follow-up — just flagging it here for visibility.

Suggested expanded list
-            $licenceFiles = ['LICENCE.md', 'licence.md', 'LICENSE.md', 'license.md', 'LICENCE', 'LICENSE'];
+            $licenceFiles = ['LICENCE.md', 'licence.md', 'LICENSE.md', 'license.md', 'LICENCE.txt', 'licence.txt', 'LICENSE.txt', 'license.txt', 'LICENCE', 'LICENSE'];

@LukeTowers LukeTowers merged commit dbe278b into wintercms:develop Feb 8, 2026
13 checks passed
@LukeTowers LukeTowers added this to the 1.2.11 milestone Feb 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants