Changeset 3222df2 for perl


Ignore:
Timestamp:
Aug 16, 2017, 12:53:41 PM (7 years ago)
Author:
Jason Gross <jasongross9@gmail.com>
Branches:
master
Children:
b807d8f
Parents:
9625c55
git-author:
Jason Gross <jgross@mit.edu> (08/06/17 00:13:19)
git-committer:
Jason Gross <jasongross9@gmail.com> (08/16/17 12:53:41)
Message:
Replace initial . with _

This is so that, e.g., we won't write to .git, .gitconfig, etc.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perl/lib/BarnOwl/Logging.pm

    r54c5395 r3222df2  
    144144Sanitizes C<FILENAME> and concatenates it with C<BASE_PATH>.
    145145
    146 In any filename, C<"/"> and any control characters (characters which
    147 match C<[:cntrl:]> get replaced by underscores.  If the resulting
    148 filename is empty or equal to C<"."> or C<"..">, it is replaced with
    149 C<"weird">.
     146In any filename, C<"/">, any control characters (characters which
     147match C<[:cntrl:]>), and any initial C<"."> characters get replaced by
     148underscores.  If the resulting filename is empty, it is replaced with
     149C<"_EMPTY_">.
    150150
    151151=cut
     
    155155    my $filename = shift;
    156156    $filename =~ s/[[:cntrl:]\/]/_/g;
    157     if ($filename eq '' || $filename eq '.' || $filename eq '..') {
    158         $filename = 'weird';
    159     }
     157    $filename =~ s/^\./_/g; # handle ., .., and hidden files
     158    $filename = '_EMPTY_' if $filename eq '';
    160159    # The original C code also removed characters less than '!' and
    161160    # greater than or equal to '~', marked file names beginning with a
Note: See TracChangeset for help on using the changeset viewer.