Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
915 B

  1. package URI::file::Unix;
  2. require URI::file::Base;
  3. @ISA=qw(URI::file::Base);
  4. use strict;
  5. use URI::Escape qw(uri_unescape);
  6. sub extract_path
  7. {
  8. my($class, $path) = @_;
  9. # tidy path
  10. $path =~ s,//+,/,g;
  11. $path =~ s,(/\.)+/,/,g;
  12. $path = "./$path" if $path =~ m,^[^:/]+:,,; # look like "scheme:"
  13. $path;
  14. }
  15. sub file
  16. {
  17. my $class = shift;
  18. my $uri = shift;
  19. my @path;
  20. my $auth = $uri->authority;
  21. if (defined($auth)) {
  22. if (lc($auth) ne "localhost") {
  23. $auth = uri_unescape($auth);
  24. unless ($class->is_this_host($auth)) {
  25. push(@path, "", "", $auth);
  26. }
  27. }
  28. }
  29. my @ps = $uri->path_segments;
  30. shift @ps if @path;
  31. push(@path, @ps);
  32. for (@path) {
  33. # Unix file/directory names are not allowed to contain '\0' or '/'
  34. return if /\0/;
  35. return if /\//; # should we really?
  36. }
  37. join("/", @path);
  38. }
  39. 1;