Changeset 24829 for main/trunk/greenstone2/perllib
- Timestamp:
- 2011-11-30T17:48:15+13:00 (12 years ago)
- Location:
- main/trunk/greenstone2/perllib
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/inexport.pm
r24344 r24829 1035 1035 1036 1036 $situated_dir =~ s/[\\\/]+$//; # remove tailing slashes 1037 $situated_dir = ~ s/\\/\\\\/g; # need to protect windows slash \in regular expression1037 $situated_dir = &util::filename_to_regex($situated_dir); # need to escape windows slash \ and brackets in regular expression 1038 1038 1039 1039 # Go through existing_files, and mark anything that is contained -
main/trunk/greenstone2/perllib/plugins/DirectoryPlugin.pm
r24349 r24829 481 481 foreach my $ek (@extrametakeys) { 482 482 my ($subdir_re,$extrakey_dir) = &File::Basename::fileparse($ek); 483 $extrakey_dir =~ s/\\\./\./g; # remove RE syntax for . 484 $extrakey_dir =~ s/\\\\/\\/g; # remove RE syntax for \ 483 $extrakey_dir = &util::unregex_filename($extrakey_dir); 485 484 486 485 my $dirsep_re = &util::get_re_dirsep(); 487 486 488 my $ek_non_re = $ek; 489 $ek_non_re =~ s/\\\./\./g; # remove RE syntax for . 490 $ek_non_re =~ s/\\\\/\\/g; # remove RE syntax for \ 487 my $ek_non_re = &util::unregex_filename($ek); 491 488 if ($ek_non_re =~ m/$dirsep_re/) { # specifies at least one directory 492 489 my $md = $extrametadata{$ek}; -
main/trunk/greenstone2/perllib/plugouts/BasePlugout.pm
r24404 r24829 735 735 # if (defined $collect_dir) { 736 736 # my $collect_dir_re_safe = $collect_dir; 737 # $collect_dir_re_safe =~ s/\\/\\\\/g; 737 # $collect_dir_re_safe =~ s/\\/\\\\/g; # use &util::filename_to_regex() 738 738 # $collect_dir_re_safe =~ s/\./\\./g;## 739 739 -
main/trunk/greenstone2/perllib/plugouts/DSpacePlugout.pm
r24402 r24829 300 300 $real_filename =~ s/^\\(.*)/$1/i; 301 301 if (-e $real_filename) { 302 # escape backslashes in path for upcoming regex match 303 my $escaped_source_filename = $source_filename; 304 $escaped_source_filename =~ s/\\/\\\\/g; 302 # escape backslashes and brackets in path for upcoming regex match 303 my $escaped_source_filename = &util::filename_to_regex($source_filename); 305 304 if ($real_filename =~ m/$escaped_source_filename$/) { 306 305 next; -
main/trunk/greenstone2/perllib/plugouts/FedoraMETSPlugout.pm
r22465 r24829 613 613 614 614 my $gsdl_href = &util::filename_cat($working_dir, $fname); 615 $collectparent = ~ s/\\/\\\\/g;# escape reserved metacharacter \ in path (by replacing it with \\) for substitution615 $collectparent = &util::filename_to_regex($collectparent); # escape reserved metacharacter \ in path (by replacing it with \\) for substitution 616 616 $gsdl_href =~ s/^$collectparent(\/|\\)?//; # remove the collectparent path in gsdl_href and any trailing slash 617 617 $gsdl_href =~ s/\\/\//g; # make sure we have url paths (which only use / not \) … … 744 744 745 745 my $gsdl_href = &util::filename_cat($working_dir,$assfilePath); 746 $collectparent = ~ s/\\/\\\\/g;# escape reserved metacharacter \ in path (by replacing it with \\) for substitution746 $collectparent = &util::filename_to_regex($collectparent); # escape reserved metacharacter \ in path (by replacing it with \\) for substitution 747 747 $gsdl_href =~ s/^$collectparent(\/|\\)?//; # remove the collectparent path in gsdl_href and any trailing slash 748 748 $gsdl_href =~ s/\\/\//g; # make sure we have url paths (which only use / not \) -
main/trunk/greenstone2/perllib/strings.properties
r24754 r24829 332 332 schedule.frequency.daily:Re-build every day 333 333 schedule.frequency.weekly:Re-build every week 334 schedule.filepath_warning:**** Warning: schedule.pl may not work when Greenstone is installed in a path containing brackets and/or spaces: %s. 334 335 schedule.action:How to set up automatic re-building 335 336 schedule.action.add:Schedule automatic re-building -
main/trunk/greenstone2/perllib/util.pm
r24563 r24829 839 839 # need to put single backslash back to double so that regex works 840 840 if ($ENV{'GSDLOS'} =~ /^windows$/i) { 841 $filename =~ s/\\/\\\\/g; 842 } 841 $filename =~ s/\\/\\\\/g; 842 } 843 844 # note that the first part of a substitution is a regex, so RE chars need to be escaped, 845 # the second part of a substitution is not a regex, so for e.g. full-stop can be specified literally 846 $filename =~ s/\./\\./g; # in case there are extensions/other full stops, escape them 847 $filename =~ s@\(@\\(@g; # escape brackets 848 $filename =~ s@\)@\\)@g; # escape brackets 849 850 return $filename; 851 } 852 853 sub unregex_filename { 854 my $filename = shift (@_); 855 856 # need to put doubled backslashes for regex back to single 857 $filename =~ s/\\\\/\\/g; # remove RE syntax for \ 858 $filename =~ s/\\\./\./g; # remove RE syntax for . 859 $filename =~ s@\\\(@(@g; # remove RE syntax for ( => "\(" turns into "(" 860 $filename =~ s@\\\)@)@g; # remove RE syntax for ) => "\)" turns into ")" 843 861 return $filename; 844 862 } … … 928 946 if ($ENV{'GSDLOS'} =~ /^windows$/i) 929 947 { 930 my $escaped_val = $val; 931 $escaped_val =~ s/\\/\\\\/g; # escape any Windows backslashes for upcoming regex 948 my $escaped_val = &filename_to_regex($val); # escape any Windows backslashes and brackets for upcoming regex 932 949 if (!defined($ENV{$var})) { 933 950 $ENV{$var} = "$val"; … … 953 970 if ($ENV{'GSDLOS'} =~ /^windows$/i) 954 971 { 955 my $escaped_val = $val; 956 $escaped_val =~ s/\\/\\\\/g; # escape any Windows backslashes for upcoming regex 972 my $escaped_val = &filename_to_regex($val); # escape any Windows backslashes and brackets for upcoming regex 957 973 if (!defined($ENV{$var})) { 958 974 $ENV{$var} = "$val"; … … 1048 1064 } 1049 1065 1050 $within_dir =~ s/\\/\\\\/g; # escape DOS style file separator 1051 1066 $within_dir = &filename_to_regex($within_dir); # escape DOS style file separator and brackets 1052 1067 if ($filename =~ m/^$within_dir(.*)$/) { 1053 1068 $filename = $1;
Note:
See TracChangeset
for help on using the changeset viewer.