summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl/lib/URI/_userpass.pm
diff options
context:
space:
mode:
authorSiep Kroonenberg <siepo@cybercomm.nl>2011-02-27 21:02:16 +0000
committerSiep Kroonenberg <siepo@cybercomm.nl>2011-02-27 21:02:16 +0000
commitf64d7ab506e73cd9643989e77ffd13654c3d5f55 (patch)
tree871f8105d75c09f2fba9e41a92fcad5d472c1d24 /Master/tlpkg/tlperl/lib/URI/_userpass.pm
parentcdce81b54ed4a0982aa4787b1db3e446aa84b59a (diff)
LWP module plus dependencies
git-svn-id: svn://tug.org/texlive/trunk@21533 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/tlperl/lib/URI/_userpass.pm')
-rw-r--r--Master/tlpkg/tlperl/lib/URI/_userpass.pm51
1 files changed, 51 insertions, 0 deletions
diff --git a/Master/tlpkg/tlperl/lib/URI/_userpass.pm b/Master/tlpkg/tlperl/lib/URI/_userpass.pm
new file mode 100644
index 00000000000..a0361ae0dd7
--- /dev/null
+++ b/Master/tlpkg/tlperl/lib/URI/_userpass.pm
@@ -0,0 +1,51 @@
+package URI::_userpass;
+
+use strict;
+use URI::Escape qw(uri_unescape);
+
+sub user
+{
+ my $self = shift;
+ my $info = $self->userinfo;
+ if (@_) {
+ my $new = shift;
+ my $pass = defined($info) ? $info : "";
+ $pass =~ s/^[^:]*//;
+
+ if (!defined($new) && !length($pass)) {
+ $self->userinfo(undef);
+ } else {
+ $new = "" unless defined($new);
+ $new =~ s/%/%25/g;
+ $new =~ s/:/%3A/g;
+ $self->userinfo("$new$pass");
+ }
+ }
+ return unless defined $info;
+ $info =~ s/:.*//;
+ uri_unescape($info);
+}
+
+sub password
+{
+ my $self = shift;
+ my $info = $self->userinfo;
+ if (@_) {
+ my $new = shift;
+ my $user = defined($info) ? $info : "";
+ $user =~ s/:.*//;
+
+ if (!defined($new) && !length($user)) {
+ $self->userinfo(undef);
+ } else {
+ $new = "" unless defined($new);
+ $new =~ s/%/%25/g;
+ $self->userinfo("$user:$new");
+ }
+ }
+ return unless defined $info;
+ return unless $info =~ s/^[^:]*://;
+ uri_unescape($info);
+}
+
+1;