Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package perl-String-Util for openSUSE:Factory checked in at 2021-04-12 12:36:40 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-String-Util (Old) and /work/SRC/openSUSE:Factory/.perl-String-Util.new.2401 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-String-Util" Mon Apr 12 12:36:40 2021 rev:2 rq:884097 version:1.32 Changes: -------- --- /work/SRC/openSUSE:Factory/perl-String-Util/perl-String-Util.changes 2020-10-26 16:21:10.475169730 +0100 +++ /work/SRC/openSUSE:Factory/.perl-String-Util.new.2401/perl-String-Util.changes 2021-04-12 12:39:33.961522824 +0200 @@ -1,0 +2,11 @@ +Sat Mar 27 03:09:02 UTC 2021 - Tina M??ller <timueller+p...@suse.de> + +- updated to 1.32 + see /usr/share/doc/packages/perl-String-Util/Changes + + 1.32 2021-03-26 14:06:00 PDT + 1.32 2021-03-26 09:27:35 PDT + - Per bug reports, trim(undef) will return undef + - Add a custom separtor option to sanitize + +------------------------------------------------------------------- Old: ---- String-Util-1.31.tar.gz New: ---- String-Util-1.32.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-String-Util.spec ++++++ --- /var/tmp/diff_new_pack.cGVmJx/_old 2021-04-12 12:39:34.481523429 +0200 +++ /var/tmp/diff_new_pack.cGVmJx/_new 2021-04-12 12:39:34.481523429 +0200 @@ -1,7 +1,7 @@ # # spec file for package perl-String-Util # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,18 +16,16 @@ # +%define cpan_name String-Util Name: perl-String-Util -Version: 1.31 +Version: 1.32 Release: 0 -%define cpan_name String-Util Summary: String processing utility functions License: Artistic-1.0 OR GPL-1.0-or-later -Group: Development/Libraries/Perl URL: https://metacpan.org/release/%{cpan_name} Source0: https://cpan.metacpan.org/authors/id/B/BA/BAKERSCOT/%{cpan_name}-%{version}.tar.gz Source1: cpanspec.yml BuildArch: noarch -BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: perl BuildRequires: perl-macros BuildRequires: perl(Module::Build::Tiny) >= 0.034 @@ -39,7 +37,7 @@ strings in various ways. %prep -%setup -q -n %{cpan_name}-%{version} +%autosetup -n %{cpan_name}-%{version} %build perl Build.PL --installdirs=vendor @@ -53,7 +51,6 @@ %perl_gen_filelist %files -f %{name}.files -%defattr(-,root,root,755) %doc Changes docs README %license LICENSE ++++++ String-Util-1.31.tar.gz -> String-Util-1.32.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/String-Util-1.31/Changes new/String-Util-1.32/Changes --- old/String-Util-1.31/Changes 2020-07-27 19:28:12.000000000 +0200 +++ new/String-Util-1.32/Changes 2021-03-26 22:06:02.000000000 +0100 @@ -1,3 +1,11 @@ +1.32 2021-03-26 14:06:00 PDT + +1.32 2021-03-26 09:27:35 PDT + + - Per bug reports, trim(undef) will return undef + + - Add a custom separtor option to sanitize + 1.31 2020-07-27 10:28:07 PDT - Deprecate randcrypt() as it's not secure in 2020 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/String-Util-1.31/META.json new/String-Util-1.32/META.json --- old/String-Util-1.31/META.json 2020-07-27 19:28:12.000000000 +0200 +++ new/String-Util-1.32/META.json 2021-03-26 22:06:02.000000000 +0100 @@ -59,13 +59,13 @@ "web" : "https://github.com/scottchiefbaker/String-Util" } }, - "version" : "1.31", + "version" : "1.32", "x_contributors" : [ "Dan Book <gri...@gmail.com>", "Scott Baker <scott.ba...@directlink.coop>" ], - "x_generated_by_perl" : "v5.24.4", - "x_serialization_backend" : "Cpanel::JSON::XS version 4.12", + "x_generated_by_perl" : "v5.26.3", + "x_serialization_backend" : "Cpanel::JSON::XS version 4.25", "x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later", "x_static_install" : 1 } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/String-Util-1.31/META.yml new/String-Util-1.32/META.yml --- old/String-Util-1.31/META.yml 2020-07-27 19:28:12.000000000 +0200 +++ new/String-Util-1.32/META.yml 2021-03-26 22:06:02.000000000 +0100 @@ -28,11 +28,11 @@ bugtracker: https://github.com/scottchiefbaker/String-Util/issues homepage: https://github.com/scottchiefbaker/String-Util repository: https://github.com/scottchiefbaker/String-Util.git -version: '1.31' +version: '1.32' x_contributors: - 'Dan Book <gri...@gmail.com>' - 'Scott Baker <scott.ba...@directlink.coop>' -x_generated_by_perl: v5.24.4 +x_generated_by_perl: v5.26.3 x_serialization_backend: 'YAML::Tiny version 1.73' x_spdx_expression: 'Artistic-1.0-Perl OR GPL-1.0-or-later' x_static_install: 1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/String-Util-1.31/README new/String-Util-1.32/README --- old/String-Util-1.31/README 2020-07-27 19:28:12.000000000 +0200 +++ new/String-Util-1.32/README 2021-03-26 22:06:02.000000000 +0100 @@ -207,9 +207,9 @@ both are undef. If only one is undef, or if they are both defined but different, returns false. Here are some examples and what they return. - $var = eqq('x', 'x'), "\n"; # True - $var = eqq('x', undef), "\n"; # False - $var = eqq(undef, undef), "\n"; # True + $var = eqq('x', 'x'); # True + $var = eqq('x', undef); # False + $var = eqq(undef, undef); # True Note: equndef() is an alias to this function. It is considered deprecated. It may be removed in future versions. @@ -219,9 +219,9 @@ The opposite of neqq, returns true if the two values are *not* the same. Here are some examples and what they return. - $var = neqq('x', 'x'), "\n"; # False - $var = neqq('x', undef), "\n"; # True - $var = neqq(undef, undef), "\n"; # False + $var = neqq('x', 'x'); # False + $var = neqq('x', undef); # True + $var = neqq(undef, undef); # False Note: neundef() is an alias to this function. It is considered deprecated. It may be removed in future versions. @@ -272,34 +272,31 @@ $var = contains("Hello world", "Hello"); # true $var = contains("Hello world", "llo wor"); # true $var = contains("Hello world", "QQQ"); # false + + # Also works with grep + @arr = grep { contains("cat") } @input; startswith($string, $substring) Checks if the string starts with the characters in substring - $var = startwidth("Hello world", "Hello"); # true - $var = startwidth("Hello world", "H"); # true - $var = startwidth("Hello world", "Q"); # false - - sanitize($string) - - Sanitize all non alpha-numeric characters in a string to underscores. - This is useful to take a URL, or filename, or text description and know - you can use it safely in a URL or a filename. - - Note: This will remove any trailing or leading '_' on the string - - $var = sanitize("http://www.google.com/") # http_www_google_com - $var = sanitize("foo_bar()"; # foo_bar - $var = sanitize("/path/to/file.txt"); # path_to_file_txt + $var = startwith("Hello world", "Hello"); # true + $var = startwith("Hello world", "H"); # true + $var = startwith("Hello world", "Q"); # false + + # Also works with grep + @arr = grep { startswith("X") } @input; endswith($string, $substring) Checks if the string ends with the characters in substring - $var = endswidth("Hello world", "world"); # true - $var = endswidth("Hello world", "d"); # true - $var = endswidth("Hello world", "QQQ"); # false + $var = endswith("Hello world", "world"); # true + $var = endswith("Hello world", "d"); # true + $var = endswith("Hello world", "QQQ"); # false + + # Also works with grep + @arr = grep { endswith("z") } @input; crunchlines($string) @@ -309,6 +306,19 @@ $var = crunchlines("x\n\n\nx"); # "x\nx"; + sanitize($string, $separator = "_") + + Sanitize all non alpha-numeric characters in a string to underscores. + This is useful to take a URL, or filename, or text description and know + you can use it safely in a URL or a filename. + + Note: This will remove any trailing or leading '_' on the string + + $var = sanitize("http://www.google.com/") # http_www_google_com + $var = sanitize("foo_bar()"; # foo_bar + $var = sanitize("/path/to/file.txt"); # path_to_file_txt + $var = sanitize("Big yellow bird!", "."); # Big.yellow.bird + file_get_contents($string, $boolean) Read an entire file from disk into a string. Returns undef if the file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/String-Util-1.31/lib/String/Util.pm new/String-Util-1.32/lib/String/Util.pm --- old/String-Util-1.31/lib/String/Util.pm 2020-07-27 19:28:12.000000000 +0200 +++ new/String-Util-1.32/lib/String/Util.pm 2021-03-26 22:06:02.000000000 +0100 @@ -3,10 +3,10 @@ use strict; use warnings; use Carp; -use 5.010; +use 5.014; # version -our $VERSION = '1.31'; +our $VERSION = '1.32'; #------------------------------------------------------------------------------ @@ -190,8 +190,8 @@ sub trim { my $s = shift(); - if (!defined($s) || length($s) == 0) { - return ""; + if (!defined($s)) { + return undef; } $s =~ s/^\s*//u; @@ -211,8 +211,8 @@ sub ltrim { my $s = shift(); - if (!defined($s) || length($s) == 0) { - return ""; + if (!defined($s)) { + return undef; } $s =~ s/^\s*//u; @@ -223,8 +223,8 @@ sub rtrim { my $s = shift(); - if (!defined($s) || length($s) == 0) { - return ""; + if (!defined($s)) { + return undef; } $s =~ s/\s*$//u; @@ -295,8 +295,7 @@ $val =~ s|\"|"|g; $val =~ s|\<|<|g; $val =~ s|\>|>|g; - } - else { + } else { $val = ''; } @@ -318,9 +317,7 @@ if (hascontent($val)) { $val = htmlesc($val); - } - - else { + } else { $val = ' '; } @@ -345,6 +342,10 @@ sub jsquote { my ($str) = @_; + if (!defined($str)) { + return undef; + } + # Escape single quotes. $str =~ s|'|\\'|gs; @@ -557,11 +558,11 @@ # path information for WC our %PATHS = ( - wc => '/usr/bin/wc', - shuf => '/usr/bin/shuf', + wc => '/usr/bin/wc', + shuf => '/usr/bin/shuf', words => '/usr/share/dict/words', - head => '/usr/bin/head', - tail => '/usr/bin/tail', + head => '/usr/bin/head', + tail => '/usr/bin/tail', ); sub randword { @@ -671,9 +672,9 @@ are undef. If only one is undef, or if they are both defined but different, returns false. Here are some examples and what they return. - $var = eqq('x', 'x'), "\n"; # True - $var = eqq('x', undef), "\n"; # False - $var = eqq(undef, undef), "\n"; # True + $var = eqq('x', 'x'); # True + $var = eqq('x', undef); # False + $var = eqq(undef, undef); # True B<Note:> equndef() is an alias to this function. It is considered deprecated. It may be removed in future versions. @@ -714,9 +715,9 @@ The opposite of neqq, returns true if the two values are *not* the same. Here are some examples and what they return. - $var = neqq('x', 'x'), "\n"; # False - $var = neqq('x', undef), "\n"; # True - $var = neqq(undef, undef), "\n"; # False + $var = neqq('x', 'x'); # False + $var = neqq('x', undef); # True + $var = neqq(undef, undef); # False B<Note:> neundef() is an alias to this function. It is considered deprecated. It may be removed in future versions. @@ -899,11 +900,17 @@ $var = contains("Hello world", "llo wor"); # true $var = contains("Hello world", "QQQ"); # false + # Also works with grep + @arr = grep { contains("cat") } @input; + =cut sub contains { - my $str = shift() || ""; - my $substr = shift(); + my ($str, $substr) = @_; + + if (!defined($str)) { + return undef; + } if (!$substr) { $substr = $str; @@ -919,15 +926,21 @@ Checks if the string starts with the characters in substring - $var = startwidth("Hello world", "Hello"); # true - $var = startwidth("Hello world", "H"); # true - $var = startwidth("Hello world", "Q"); # false + $var = startwith("Hello world", "Hello"); # true + $var = startwith("Hello world", "H"); # true + $var = startwith("Hello world", "Q"); # false + + # Also works with grep + @arr = grep { startswith("X") } @input; =cut sub startswith { - my $str = shift() || ""; - my $substr = shift(); + my ($str, $substr) = @_; + + if (!defined($str)) { + return undef; + } if (!$substr) { $substr = $str; @@ -939,43 +952,25 @@ return $ret; } -=head2 sanitize($string) - -Sanitize all non alpha-numeric characters in a string to underscores. -This is useful to take a URL, or filename, or text description and know -you can use it safely in a URL or a filename. - -B<Note:> This will remove any trailing or leading '_' on the string - - $var = sanitize("http://www.google.com/") # http_www_google_com - $var = sanitize("foo_bar()"; # foo_bar - $var = sanitize("/path/to/file.txt"); # path_to_file_txt - -=cut - -sub sanitize { - my $str = shift(); - - $str =~ s/[\W_]+/_/g; - $str =~ s/\A_+//g; - $str =~ s/_+\z//g; - - return $str; -} - =head2 endswith($string, $substring) Checks if the string ends with the characters in substring - $var = endswidth("Hello world", "world"); # true - $var = endswidth("Hello world", "d"); # true - $var = endswidth("Hello world", "QQQ"); # false + $var = endswith("Hello world", "world"); # true + $var = endswith("Hello world", "d"); # true + $var = endswith("Hello world", "QQQ"); # false + + # Also works with grep + @arr = grep { endswith("z") } @input; =cut sub endswith { - my $str = shift() || ""; - my $substr = shift(); + my ($str, $substr) = @_; + + if (!defined($str)) { + return undef; + } if (!$substr) { $substr = $str; @@ -1007,6 +1002,10 @@ sub crunchlines { my ($str) = @_; + if (!defined($str)) { + return undef; + } + while($str =~ s|\n[ \t]*\n|\n|gs) {} @@ -1019,6 +1018,43 @@ # crunchlines #------------------------------------------------------------------------------ +=head2 sanitize($string, $separator = "_") + +Sanitize all non alpha-numeric characters in a string to underscores. +This is useful to take a URL, or filename, or text description and know +you can use it safely in a URL or a filename. + +B<Note:> This will remove any trailing or leading '_' on the string + + $var = sanitize("http://www.google.com/") # http_www_google_com + $var = sanitize("foo_bar()"; # foo_bar + $var = sanitize("/path/to/file.txt"); # path_to_file_txt + $var = sanitize("Big yellow bird!", "."); # Big.yellow.bird + +=cut + +sub sanitize { + my $str = shift(); + my $sep = shift() // "_"; + + if (!defined($str)) { + return undef; + } + + # Convert multiple non-word sequences to the separator + $str =~ s/[\W_]+/$sep/g; + + # The separator is a literal character so we quotemeta it + $sep = quotemeta($sep); + # Remove any separators at the beginning and end + $str =~ s/\A$sep+//; + $str =~ s/$sep+\z//; + + return $str; +} + +########################################################################### + =head2 file_get_contents($string, $boolean) Read an entire file from disk into a string. Returns undef if the file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/String-Util-1.31/t/test.t new/String-Util-1.32/t/test.t --- old/String-Util-1.31/t/test.t 2020-07-27 19:28:12.000000000 +0200 +++ new/String-Util-1.32/t/test.t 2021-03-26 22:06:02.000000000 +0100 @@ -20,6 +20,9 @@ # crunch #------------------------------------------------------------------------------ +is(crunchlines("x\n\n\nx"), "x\nx", "crunchlines with three \\ns"); +is(crunchlines("x\nx") , "x\nx", "crunchlines with one \\ns"); +is(crunchlines(undef) , undef , "crunchlines with undef"); #------------------------------------------------------------------------------ # hascontent @@ -48,14 +51,16 @@ # # basic trimming -is(trim(undef) , "" , 'trim undef'); +is(trim(undef) , undef , 'trim undef'); is(trim(" Perl ") , "Perl" , 'trim spaces'); is(trim("\t\tPerl\t\t") , "Perl" , 'trim tabs'); is(trim("\n\n\nPerl") , "Perl" , 'trim \n'); is(trim("\n\n\t\nPerl \t\n") , "Perl" , 'trim all three'); -is(ltrim("\n\n\t\nPerl ") , "Perl " , 'ltrim'); -is(rtrim("\n\tPerl ") , "\n\tPerl" , 'rtrim'); +is(ltrim("\n\n\t\nPerl "), "Perl " , 'ltrim'); +is(ltrim(undef) , undef, 'ltrim undef'); +is(rtrim("\n\tPerl ") , "\n\tPerl" , 'rtrim'); +is(rtrim(undef) , undef, 'rtrim undef'); # # trim @@ -79,10 +84,11 @@ # startswith $val = "Quick brown fox"; -ok(startswith("Quick brown fox", 'Q') , "Startswidth char"); -ok(startswith("Quick brown fox", 'Quick') , "Startswidth word"); -ok(!startswith("Quick brown fox", 'z') , "Does NOT start with char"); -ok(!startswith("Quick brown fox", 'Qqq') , "Does NOT start with string"); +ok(startswith("Quick brown fox" , 'Q') , "Startswidth char"); +ok(startswith("Quick brown fox" , 'Quick') , "Startswidth word"); +ok(!startswith("Quick brown fox", 'z') , "Does NOT start with char"); +ok(!startswith("Quick brown fox", 'Qqq') , "Does NOT start with string"); +is(startswith(undef, 'foo') , undef , "Startswidth undef"); #------------------------------------------------------------------------------ @@ -90,10 +96,11 @@ # endswith $val = "Quick brown fox"; -ok(endswith($val, 'x') , "Endswidth char"); -ok(endswith($val, 'fox') , "Endswidth word"); -ok(endswith($val, ' fox') , "Endswidth space word"); -ok(!endswith($val, 'foq') , "Does not end width string"); +ok(endswith($val, 'x') , "Endswith char"); +ok(endswith($val, 'fox') , "Endswith word"); +ok(endswith($val, ' fox') , "Endswith space word"); +ok(!endswith($val, 'foq') , "Does not end with string"); +is(endswith(undef, 'foo'), undef , "Endswith undef"); #------------------------------------------------------------------------------ @@ -104,6 +111,7 @@ ok(contains($val, 'uick') , "Contains word 2"); ok(contains($val, 'n f') , "Contains word with space"); ok(!contains($val, 'bri') , "Does not contains word"); +is(contains(undef, 'foo') , undef , "Contains undef"); #------------------------------------------------------------------------------ @@ -212,6 +220,8 @@ is(sanitize("foo_bar()") , 'foo_bar' , 'Sanitize function name'); is(sanitize("/path/to/file.txt") , 'path_to_file_txt' , 'Sanitize path'); +is(sanitize("Hello there!!!", '.') , 'Hello.there' , 'Sanitize with a custom separator'); + #------------------------------------------------------------------------------ # randword # Not sure how to test this besides making sure it actually runs.