From: b Date: Sat, 9 Mar 2024 19:55:55 +0000 (+0000) Subject: change some regexp to use 'regex_sets' X-Git-Tag: v1.1.4 X-Git-Url: http://bicyclesonthemoon.info/git-projects/?a=commitdiff_plain;h=2b44cff4fd1df24df3fc9d354e0848e3f0516ef3;p=botm%2Fcommon-perl change some regexp to use 'regex_sets' --- diff --git a/botm_common.pm b/botm_common.pm index 33572f3..200d14c 100644 --- a/botm_common.pm +++ b/botm_common.pm @@ -19,6 +19,7 @@ use strict; #use warnings; use utf8; use feature 'state'; +use experimental 'regex_sets'; use Encode::Locale; use Encode ('encode', 'decode'); @@ -26,7 +27,7 @@ use File::Copy; use Exporter; -our $VERSION = '1.1.3'; +our $VERSION = '1.1.4'; our @ISA = qw(Exporter); our @EXPORT = (); our @EXPORT_OK = ( @@ -464,7 +465,7 @@ sub read_data_file { } } # Line starts with a name followed by colon/equal sign. Save the value - elsif ($line =~ /^([ -9;-<>-~]+)((:[ \t])|=)/s) { + elsif ($line =~ /^((?[[\ -~]-[:=]])+)((:[ \t])|=)/s) { $name = lc($1); $value = $'; @@ -618,7 +619,7 @@ sub write_postdata_file { return 1; } -# read_list_file() reads a list file and returns an arral with the data values. +# read_list_file() reads a list file and returns an array with the data values. # # $file is the path to the file to read. # file will be opened, read, and closed. @@ -884,7 +885,7 @@ use constant HTTP_STATUS => { sub http_header_line { (my $name, my $value, my $single_line) = @_; if ( - ($name !~ /^[\x21\x23-\x27\x2a\x2b\x2d\x2e\x30-\x39\x3d\x41-\x5a\x5e-\x7a\x7c\x7e]+$/s) || + ($name !~ /^(?[[\x21-\x7e]-["\(\),\/:;<>\?\[\\\]\{\|\}]])+$/s) || ($value !~ /^([^\x00-\x1f\x7f]|((\r?\n)?[ \t]))*$/s) ) { # name: 'token' @@ -970,18 +971,18 @@ sub http_header_content_length { sub http_header_content_disposition { (my $type, my $filename) = @_; - if ($type !~ /^[\x21\x23-\x27\x2a\x2b\x2d\x2e\x30-\x39\x3d\x41-\x5a\x5e-\x7a\x7c\x7e]+$/s) { + if ($type !~ /^(?[[\x21-\x7e]-["\(\),\/:;<>\?\[\\\]\{\}]])+$/s) { return ''; } my $value = lc($type); if ($filename ne '') { $value .= '; filename'; - if ($filename =~ /^[\x21\x23-\x27\x2a\x2b\x2d\x2e\x30-\x39\x3d\x41-\x5a\x5e-\x7a\x7c\x7e]+$/s) { + if ($filename =~ /^(?[[\x21-\x7e]-["\(\),\/:;<>\?\[\\\]\{\}]])+$/s) { # token $value .= '='.$filename; } - elsif ($filename =~ /^[\x20-\x21\x23-\x5b\x5d-\x7e]*$/s) { + elsif ($filename =~ /^(?[[\x20-\x7e]-["\\]])*$/s) { # quoted-string $value .= '="'.$filename.'"'; } @@ -997,7 +998,7 @@ sub http_header_content_disposition { # sub http_header_content_type { # (my $media_type, my $parameters) = @_; - # if ($media_type !~ /^[\x21\x23-\x27\x2a\x2b\x2d\x2e\x30-\x39\x3d\x41-\x5a\x5e-\x7a\x7c\x7e]+\/[\x21\x23-\x27\x2a\x2b\x2d\x2e\x30-\x39\x3d\x41-\x5a\x5e-\x7a\x7c\x7e]+$/s) { + # if ($media_type !~ /^(?[[\x21-\x7e]-["\(\),\/:;<>\?\[\\\]\{\}])+$/s) { # return '' # } # my $value = media_type;