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.

68 lines
1.2 KiB

  1. package URI::pop; # RFC 2384
  2. require URI::_server;
  3. @ISA=qw(URI::_server);
  4. use strict;
  5. use URI::Escape qw(uri_unescape);
  6. sub default_port { 110 }
  7. #pop://<user>;auth=<auth>@<host>:<port>
  8. sub user
  9. {
  10. my $self = shift;
  11. my $old = $self->userinfo;
  12. if (@_) {
  13. my $new_info = $old;
  14. $new_info = "" unless defined $new_info;
  15. $new_info =~ s/^[^;]*//;
  16. my $new = shift;
  17. if (!defined($new) && !length($new_info)) {
  18. $self->userinfo(undef);
  19. } else {
  20. $new = "" unless defined $new;
  21. $new =~ s/%/%25/g;
  22. $new =~ s/;/%3B/g;
  23. $self->userinfo("$new$new_info");
  24. }
  25. }
  26. return unless defined $old;
  27. $old =~ s/;.*//;
  28. return uri_unescape($old);
  29. }
  30. sub auth
  31. {
  32. my $self = shift;
  33. my $old = $self->userinfo;
  34. if (@_) {
  35. my $new = $old;
  36. $new = "" unless defined $new;
  37. $new =~ s/(^[^;]*)//;
  38. my $user = $1;
  39. $new =~ s/;auth=[^;]*//i;
  40. my $auth = shift;
  41. if (defined $auth) {
  42. $auth =~ s/%/%25/g;
  43. $auth =~ s/;/%3B/g;
  44. $new = ";AUTH=$auth$new";
  45. }
  46. $self->userinfo("$user$new");
  47. }
  48. return unless defined $old;
  49. $old =~ s/^[^;]*//;
  50. return uri_unescape($1) if $old =~ /;auth=(.*)/i;
  51. return;
  52. }
  53. 1;