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.

51 lines
1.0 KiB

  1. package URI::_userpass;
  2. use strict;
  3. use URI::Escape qw(uri_unescape);
  4. sub user
  5. {
  6. my $self = shift;
  7. my $info = $self->userinfo;
  8. if (@_) {
  9. my $new = shift;
  10. my $pass = defined($info) ? $info : "";
  11. $pass =~ s/^[^:]*//;
  12. if (!defined($new) && !length($pass)) {
  13. $self->userinfo(undef);
  14. } else {
  15. $new = "" unless defined($new);
  16. $new =~ s/%/%25/g;
  17. $new =~ s/:/%3A/g;
  18. $self->userinfo("$new$pass");
  19. }
  20. }
  21. return unless defined $info;
  22. $info =~ s/:.*//;
  23. uri_unescape($info);
  24. }
  25. sub password
  26. {
  27. my $self = shift;
  28. my $info = $self->userinfo;
  29. if (@_) {
  30. my $new = shift;
  31. my $user = defined($info) ? $info : "";
  32. $user =~ s/:.*//;
  33. if (!defined($new) && !length($user)) {
  34. $self->userinfo(undef);
  35. } else {
  36. $new = "" unless defined($new);
  37. $new =~ s/%/%25/g;
  38. $self->userinfo("$user:$new");
  39. }
  40. }
  41. return unless defined $info;
  42. return unless $info =~ s/^[^:]*://;
  43. uri_unescape($info);
  44. }
  45. 1;