Skip to content

Commit

Permalink
more boundary tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Oct 31, 2012
1 parent 470c4dd commit 9354ce2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Mojo/Content.pm
Expand Up @@ -17,7 +17,7 @@ sub body_size { croak 'Method "body_size" not implemented by subclass' }

sub boundary {
my $type = shift->headers->content_type || '';
$type =~ m!multipart.*boundary="*([a-zA-Z0-9'(),.:?\-_+/]+)!i and return $1;
$type =~ m!multipart.*boundary="?([a-zA-Z0-9'(),.:?\-_+/]+)!i and return $1;
return undef;
}

Expand Down
7 changes: 7 additions & 0 deletions t/mojo/content.t
Expand Up @@ -55,6 +55,13 @@ is $content->build_body,
"6\x0d\x0aHello \x0d\x0a6\x0d\x0aWorld!\x0d\x0a0\x0d\x0a\x0d\x0a",
'right content';

# Multipart boundary detection
$content = Mojo::Content::MultiPart->new;
$content->headers->content_type(
'multipart/form-data; boundary="azAZ09\'(),.:?-_+/"');
is $content->boundary, "azAZ09\'(),.:?-_+/", 'right boundary';
is $content->boundary, $content->build_boundary, 'same boundary';

# Tainted environment
$content = Mojo::Content::MultiPart->new;
'a' =~ /(.)/;
Expand Down

0 comments on commit 9354ce2

Please sign in to comment.