Skip to content

Commit

Permalink
use substitution again
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 20, 2015
1 parent c19f663 commit b9d985f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/Mojo/Util.pm
Expand Up @@ -392,21 +392,21 @@ sub _header {
my ($str, $cookie) = @_;

my (@tree, @part);
while ($str =~ /\G[,;\s]*([^=;, ]+)\s*/gc) {
while ($str =~ s/^[,;\s]*([^=;, ]+)\s*//) {
push @part, $1, undef;
my $expires = $cookie && @part > 2 && lc $1 eq 'expires';

# Special "expires" value
if ($expires && $str =~ /\G=\s*$EXPIRES_RE/gco) { $part[-1] = $1 }
if ($expires && $str =~ s/^=\s*$EXPIRES_RE//o) { $part[-1] = $1 }

# Quoted value
elsif ($str =~ /\G=\s*("(?:\\\\|\\"|[^"])*")/gc) { $part[-1] = unquote $1 }
elsif ($str =~ s/^=\s*("(?:\\\\|\\"|[^"])*")//) { $part[-1] = unquote $1 }

# Unquoted value
elsif ($str =~ /\G=\s*([^;, ]*)/gc) { $part[-1] = $1 }
elsif ($str =~ s/^=\s*([^;, ]*)//) { $part[-1] = $1 }

# Separator
next unless $str =~ /\G[;\s]*,\s*/gc;
next unless $str =~ s/^[;\s]*,\s*//;
push @tree, [@part];
@part = ();
}
Expand Down

0 comments on commit b9d985f

Please sign in to comment.