[Orca-checkins] r481 - orca/trunk/lib/Orca

blair at orcaware.com blair at orcaware.com
Fri Sep 2 07:31:23 PDT 2005


Author: blair at orcaware.com
Date: Fri Sep  2 07:30:26 2005
New Revision: 481

Modified:
   orca/trunk/lib/Orca/Utils.pm

Log:
Fix a problem with \ appearing in URLs because Internet Explorer will
convert these to /'s, causing URLs to fail to download.

* lib/Orca/Utils.pm
  (name_to_fsname):
    Convert \'s to |'s.


Modified: orca/trunk/lib/Orca/Utils.pm
==============================================================================
--- orca/trunk/lib/Orca/Utils.pm	(original)
+++ orca/trunk/lib/Orca/Utils.pm	Fri Sep  2 07:30:26 2005
@@ -110,7 +110,16 @@
   my ($name, $postfix_length) = @_;
 
   $name =~ s/:/_/g;
+
+  # When Internet Explorer sees a \ in a URL, it converts it into a /
+  # when it makes a request to a web server which will fail, so change
+  # the \ to a |.
+  $name =~ s:\\:|:g;
+
+  # A / cannot appear in a filename because it'll look like a
+  # directory.
   $name =~ s:/:_per_:g;
+
   $name =~ s:\s+:_:g;
   $name =~ s:%:_pct_:g;
   $name =~ s:#:_num_:g;
@@ -139,11 +148,12 @@
     my $trim_length = $max_filename_length - 23 - $postfix_length;
     $name           = substr($name, 0, $trim_length) . "-$md5";
 
-    # Be careful to convert any /, \ or + characters to _.  The /
-    # character definitely needs to be modified since / is a valid
+    # Be careful to convert any / or + characters to _ and any \'s to
+    # |'s.  The / character needs to be changed since / is a valid
     # base64 character and can't be used since we don't want a
     # directory.
-    $name =~ s:[/\\\+]:_:g;
+    $name =~ s:[/\+]:_:g;
+    $name =~ s:[\\]:|:g;
   }
 
   $name;



More information about the Orca-checkins mailing list