Making WordPress.org

Changeset 13618

Timestamp:
04/30/2024 04:41:42 AM (3 months ago)
Author:
dd32
Message:

Plugin Directory: Readme: Validate that the license field contains a likely valid license.

This adds to the existing "no license" with two new ones:

  • Warning: License appears to be not-GPL-compatible, invalid
  • Note: We could not parse the license specified, unknown

Fixes #1944.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-parser.php

    r13525 r13618  
    342342            // Handle the many cases of "License: GPLv2 - http://..."
    343343            if ( empty( $headers['license_uri'] ) && preg_match( '!(https?://\S+)!i', $headers['license'], $url ) ) {
    344                 $headers['license_uri'] = $url[1];
    345                 $headers['license']     = trim( str_replace( $url[1], '', $headers['license'] ), " -*\t\n\r\n" );
    346             }
     344                $headers['license_uri'] = trim( $url[1], " -*\t\n\r\n(" );
     345                $headers['license']     = trim( str_replace( $url[1], '', $headers['license'] ), " -*\t\n\r\n(" );
     346            }
     347
    347348            $this->license = $headers['license'];
    348349        }
    349350        if ( ! empty( $headers['license_uri'] ) ) {
    350351            $this->license_uri = $headers['license_uri'];
     352
     353
     354
     355
     356
     357
     358
     359
     360
     361
    351362        }
    352363
     
    920931    }
    921932
     933
     934
     935
     936
     937
     938
     939
     940
     941
     942
     943
     944
     945
     946
     947
     948
     949
     950
     951
     952
     953
     954
     955
     956
     957
     958
     959
     960
     961
     962
     963
     964
     965
     966
     967
     968
     969
     970
     971
     972
     973
     974
     975
     976
     977
     978
     979
     980
     981
     982
     983
     984
     985
     986
     987
     988
     989
     990
     991
     992
     993
     994
     995
     996
     997
     998
     999
     1000
     1001
     1002
     1003
     1004
     1005
     1006
     1007
     1008
     1009
     1010
     1011
     1012
     1013
     1014
     1015
     1016
     1017
     1018
     1019
     1020
     1021
     1022
     1023
    9221024}
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-validator.php

    r13524 r13618  
    145145        }
    146146
    147         if ( empty( $readme->license ) ) {
     147        if ( ) ) {
    148148            $warnings['license_missing'] = true;
     149
     150
     151
     152
    149153        }
    150154
     
    398402            case 'donate_link_missing':
    399403                return __( 'No donate link was found', 'wporg-plugins' );
     404
    400405            case 'license_missing':
    401406                return sprintf(
    402                     /* translators: 1: 'License' */
    403                     __( 'The %1$s field is missing or invalid. A GPLv2 or later compatible license should be specified.', 'wporg-plugins' ),
    404                     '<code>License</code>'
     407                    /* translators: 1: 'License', 2: Link to a compatible licenses page. */
     408                    __( 'The %1$s field is missing. <a href="%2$s">A GPLv2 or later compatible license</a> should be specified.', 'wporg-plugins' ),
     409                    '<code>License</code>',
     410                    'https://www.gnu.org/licenses/license-list.en.html'
     411                );
     412
     413            case 'invalid_license':
     414                return sprintf(
     415                    /* translators: 1: 'License', 2: Link to a compatible licenses page. */
     416                    __( 'The %1$s field appears to be invalid. <a href="%2$s">A GPLv2 or later compatible license</a> should be specified.', 'wporg-plugins' ),
     417                    '<code>License</code>',
     418                    'https://www.gnu.org/licenses/license-list.en.html'
     419                );
     420
     421            case 'unknown_license':
     422                return sprintf(
     423                    /* translators: 1: 'License', 2: Link to a compatible licenses page. */
     424                    __( 'The %1$s field could not be validated. <a href="%2$s">A GPLv2 or later compatible license</a> should be specified. The specified license may be compatible.', 'wporg-plugins' ),
     425                    '<code>License</code>',
     426                    'https://www.gnu.org/licenses/license-list.en.html'
    405427                );
    406428
Note: See TracChangeset for help on using the changeset viewer.