File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -665,4 +665,30 @@ valid(<<"xlock">>) -> true;
665665valid (<<" xpp" >>) -> true ;
666666valid (<<" xzoom" >>) -> true ;
667667valid (<<" zlib-acknowledgement" >>) -> true ;
668+ valid (<<" LicenseRef-" , IdString /binary >>) -> valid_license_ref_idstring (IdString );
668669valid (_ ) -> false .
670+
671+ valid_license_ref_idstring (<<>>) ->
672+ false ;
673+ valid_license_ref_idstring (IdString ) ->
674+ valid_license_ref_idstring (IdString , true ).
675+
676+ valid_license_ref_idstring (<<>>, Valid ) ->
677+ Valid ;
678+ valid_license_ref_idstring (_ , false ) ->
679+ false ;
680+ valid_license_ref_idstring (<<Char , Rest /binary >>, true ) ->
681+ valid_license_ref_idstring (Rest , valid_license_ref_char (Char )).
682+
683+ valid_license_ref_char (Char ) when Char >= $A , Char =< $Z ->
684+ true ;
685+ valid_license_ref_char (Char ) when Char >= $a , Char =< $z ->
686+ true ;
687+ valid_license_ref_char (Char ) when Char >= $0 , Char =< $9 ->
688+ true ;
689+ valid_license_ref_char ($- ) ->
690+ true ;
691+ valid_license_ref_char ($. ) ->
692+ true ;
693+ valid_license_ref_char (_ ) ->
694+ false .
Original file line number Diff line number Diff line change 77-include_lib (" common_test/include/ct.hrl" ).
88
99all () ->
10- [license_test , invalid_license_test ].
10+ [license_test , license_ref_test , invalid_license_test ].
1111
1212license_test (_Config ) ->
1313 true = hex_licenses :valid (<<" MIT" >>),
1414 ok .
1515
16+ license_ref_test (_Config ) ->
17+ true = hex_licenses :valid (<<" LicenseRef-Journey" >>),
18+ true = hex_licenses :valid (<<" LicenseRef-acme.1-2" >>),
19+ false = hex_licenses :valid (<<" LicenseRef-" >>),
20+ false = hex_licenses :valid (<<" LicenseRef-Journey License" >>),
21+ false = hex_licenses :valid (<<" LicenseRef-Journey_License" >>),
22+ ok .
23+
1624invalid_license_test (_Config ) ->
1725 false = hex_licenses :valid (<<" MICROSOFT" >>),
1826 ok .
You can’t perform that action at this time.
0 commit comments