BSD-2-Clause and BSD-3-Clause licenses are incorrectly flagged as not GPL-compatible

未关闭
#1,537 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@elphizu 已经在做这个了。

开始于 2026年11月12日。

  • #1538 来自 @elphizu —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
22/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
php
领域
tooling

调研方向

Start in includes/Traits/License_Utils.php, comparing get_normalized_license() (which strips hyphens) with the patterns in is_license_gpl_compatible(), which expect the hyphenated form. Check how Plugin_Header_Fields_Check and Plugin_Readme_Check call them, and extend the existing License_Utils_Tests to cover normalized BSD-2-Clause and BSD-3-Clause input. Done when both licenses pass after normalization. Pull request #1538 is already open against this issue, so review it before starting.

由索引模型根据 Issue 内容生成。

描述

Plugin Check reports BSD-2-Clause and BSD-3-Clause licenses as not GPL-compatible, even though both are GPL-compatible.

Both licenses should pass the check, just like MIT, Apache-2.0, MPL-2.0, and GPL-2.0-or-later.

The issue is in includes/Traits/License_Utils.php, where license normalization and validation do not use the same format.

  • get_normalized_license() removes hyphens. For example, BSD-3-Clause becomes BSD3Clause.
  • is_license_gpl_compatible() accepts BSD-3-Clause and BSD 3 Clause, but does not recognize BSD3Clause.
  • The validation patterns also do not include BSD-2-Clause.

Both Plugin_Header_Fields_Check and Plugin_Readme_Check normalize the license before they check compatibility. This causes both checks to report the same error.

The existing License_Utils_Tests test uses BSD-3-Clause directly without normalization. Because of this, the test passes but does not catch the issue.

Step-by-step reproduction instructions

  1. Create a plugin and add License: BSD-3-Clause to the plugin header.
  2. Add License: BSD-3-Clause to readme.txt.
  3. Run:
    wp plugin check <plugin-slug>
    
  4. Check the license validation result.

Expected result: Plugin Check accepts both BSD-2-Clause and BSD-3-Clause as GPL-compatible licenses.

Actual result: The compatibility check returns false for both licenses after normalization.

Code snippet

$normalized = $this->get_normalized_license( 'BSD-3-Clause' );
// Returns: BSD3Clause

$this->is_license_gpl_compatible( $normalized );
// Returns: false (expected true)

Environment info

  • Plugin Check version: 2.2.0
  • Branch: trunk
主要语言
PHP
星标
365
派生
135
平均合并
1 天 8 小时
30 天内合并 PR
20

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

WordPress/plugin-check 的其他 Issue

查看 WordPress/plugin-check 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。