| 1 | package URI::irc; # draft-butcher-irc-url-04 | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 2 | our $VERSION = '5.40'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use parent 'URI::_login'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use overload ( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 2 | ▶ | '""' => sub { $_[0]->as_string }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | '==' => sub { URI::_obj_eq(@_) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 0 | ▶ | '!=' => sub { !URI::_obj_eq(@_) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 14 | 2 | fallback => 1, | |||||||||||||||||||||||||||
| 15 | 2 | ); | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 2 | ▶ | sub default_port {6667} | ||||||||||||||||||||||||||
|
Subroutine
default_port: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | # ircURL = ircURI "://" location "/" [ entity ] [ flags ] [ options ] | ||||||||||||||||||||||||||||
| 20 | # ircURI = "irc" / "ircs" | ||||||||||||||||||||||||||||
| 21 | # location = [ authinfo "@" ] hostport | ||||||||||||||||||||||||||||
| 22 | # authinfo = [ username ] [ ":" password ] | ||||||||||||||||||||||||||||
| 23 | # username = *( escaped / unreserved ) | ||||||||||||||||||||||||||||
| 24 | # password = *( escaped / unreserved ) [ ";" passtype ] | ||||||||||||||||||||||||||||
| 25 | # passtype = *( escaped / unreserved ) | ||||||||||||||||||||||||||||
| 26 | # entity = [ "#" ] *( escaped / unreserved ) | ||||||||||||||||||||||||||||
| 27 | # flags = ( [ "," enttype ] [ "," hosttype ] ) | ||||||||||||||||||||||||||||
| 28 | # /= ( [ "," hosttype ] [ "," enttype ] ) | ||||||||||||||||||||||||||||
| 29 | # enttype = "," ( "isuser" / "ischannel" ) | ||||||||||||||||||||||||||||
| 30 | # hosttype = "," ( "isserver" / "isnetwork" ) | ||||||||||||||||||||||||||||
| 31 | # options = "?" option *( "&" option ) | ||||||||||||||||||||||||||||
| 32 | # option = optname [ "=" optvalue ] | ||||||||||||||||||||||||||||
| 33 | # optname = *( ALPHA / "-" ) | ||||||||||||||||||||||||||||
| 34 | # optvalue = optparam *( "," optparam ) | ||||||||||||||||||||||||||||
| 35 | # optparam = *( escaped / unreserved ) | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | # XXX: Technically, passtype is part of the protocol, but is rarely used and | ||||||||||||||||||||||||||||
| 38 | # not defined in the RFC beyond the URL ABNF. | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | # Starting the entity with /# is okay per spec, but it needs to be encoded to | ||||||||||||||||||||||||||||
| 41 | # %23 for the URL::_generic::path operations to parse correctly. | ||||||||||||||||||||||||||||
| 42 | 2 | ▶ | sub _init { | ||||||||||||||||||||||||||
|
Subroutine
_init: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 43 | 2 | my $class = shift; | |||||||||||||||||||||||||||
| 44 | 2 | my $self = $class->SUPER::_init(@_); | |||||||||||||||||||||||||||
| 45 | 2 | $$self =~ s|^((?:[^:/?\#]+:)?(?://[^/?\#]*)?)/\#|$1/%23|s; | |||||||||||||||||||||||||||
| 46 | 2 | $self; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | # Return the /# form, since this is most common for channel names. | ||||||||||||||||||||||||||||
| 50 | 5 | ▶ | sub path { | ||||||||||||||||||||||||||
|
Subroutine
path: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 51 | 5 | my $self = shift; | |||||||||||||||||||||||||||
| 52 | 5 | my ($new) = @_; | |||||||||||||||||||||||||||
| 53 | 5 | ▶ | $new =~ s|^/\#|/%23| if (@_ && defined $new); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ and defined $new
MC/DC50%1/2
@_ and defined $new
@_
defined $new
Truth table66%2/3
A and B
A= @_B= defined $new
| |||||||||||||||||||||||||||||
| 54 | 5 | ▶ | my $val = $self->SUPER::path(@_ ? $new : ()); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | 5 | $val =~ s|^/%23|/\#|; | |||||||||||||||||||||||||||
| 56 | 5 | $val; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | ▶ | sub path_query { | ||||||||||||||||||||||||||
|
Subroutine
path_query: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 60 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 61 | 0 | my ($new) = @_; | |||||||||||||||||||||||||||
| 62 | 0 | ▶ | $new =~ s|^/\#|/%23| if (@_ && defined $new); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ and defined $new
MC/DC0%0/2
@_ and defined $new
@_
defined $new
Truth table0%0/3
A and B
A= @_B= defined $new
| |||||||||||||||||||||||||||||
| 63 | 0 | ▶ | my $val = $self->SUPER::path_query(@_ ? $new : ()); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | 0 | $val =~ s|^/%23|/\#|; | |||||||||||||||||||||||||||
| 65 | 0 | $val; | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 2 | ▶ | sub as_string { | ||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 69 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 70 | 2 | my $val = $self->SUPER::as_string; | |||||||||||||||||||||||||||
| 71 | 2 | $val =~ s|^((?:[^:/?\#]+:)?(?://[^/?\#]*)?)/%23|$1/\#|s; | |||||||||||||||||||||||||||
| 72 | 2 | $val; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | ▶ | sub entity { | ||||||||||||||||||||||||||
|
Subroutine
entity: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 76 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 0 | my $path = $self->path; | |||||||||||||||||||||||||||
| 79 | 0 | $path =~ s|^/||; | |||||||||||||||||||||||||||
| 80 | 0 | my ($entity, @flags) = split /,/, $path; | |||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 83 | 0 | my $new = shift; | |||||||||||||||||||||||||||
| 84 | 0 | ▶ | $new = '' unless defined $new; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | 0 | $self->path('/' . join(',', $new, @flags)); | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 0 | ▶ | return unless length $entity; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | 0 | $entity; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 0 | ▶ | sub flags { | ||||||||||||||||||||||||||
|
Subroutine
flags: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 93 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 0 | my $path = $self->path; | |||||||||||||||||||||||||||
| 96 | 0 | $path =~ s|^/||; | |||||||||||||||||||||||||||
| 97 | 0 | my ($entity, @flags) = split /,/, $path; | |||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 100 | 0 | $self->path('/' . join(',', $entity, @_)); | |||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 0 | @flags; | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 2 | ▶ | sub options { shift->query_form(@_) } | ||||||||||||||||||||||||||
|
Subroutine
options: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 1 | ▶ | sub canonical { | ||||||||||||||||||||||||||
|
Subroutine
canonical: called CC=6 SCAR=18.1
Pod
documented
| |||||||||||||||||||||||||||||
| 109 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 110 | 1 | my $other = $self->SUPER::canonical; | |||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | # Clean up the flags | ||||||||||||||||||||||||||||
| 113 | 1 | my $path = $other->path; | |||||||||||||||||||||||||||
| 114 | 1 | $path =~ s|^/||; | |||||||||||||||||||||||||||
| 115 | 1 | my ($entity, @flags) = split /,/, $path; | |||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 5 | ▶ | my @clean = map { $_ eq 'isnick' ? 'isuser' : $_ } # convert isnick->isuser | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 118 | 5 | map {lc} | |||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | # NOTE: Allow flags from draft-mirashi-url-irc-01 as well | ||||||||||||||||||||||||||||
| 121 | 1 | grep {/^(?:is(?:user|channel|server|network|nick)|need(?:pass|key))$/i} | |||||||||||||||||||||||||||
| 122 | @flags; | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | # Only allow the first type of each category, per the Butcher draft | ||||||||||||||||||||||||||||
| 125 | 1 | my ($enttype) = grep {/^is(?:user|channel)$/} @clean; | |||||||||||||||||||||||||||
| 126 | 1 | my ($hosttype) = grep {/^is(?:server|network)$/} @clean; | |||||||||||||||||||||||||||
| 127 | 1 | my @others = grep {/^need(?:pass|key)$/} @clean; | |||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 1 | ▶ | my @new = ($enttype ? $enttype : (), $hosttype ? $hosttype : (), @others,); | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 1 | ▶ | unless (join(',', @new) eq join(',', @flags)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 132 | 1 | ▶ | $other = $other->clone if $other == $self; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 133 | 1 | $other->path('/' . join(',', $entity, @new)); | |||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 1 | $other; | |||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 2 | 1; | |||||||||||||||||||||||||||