my $str = shift;
my $enc = shift;
-
- @_ = $str =~ m/([^=]*)=\?([^?]+)\?([QqBb])\?([^?]+)\?=([^=]*)/g;
-
+ @_ = $str =~ m/(.*?)=\?([^?]+)\?([QqBb])\?([^?]+)\?=([^=]*)/gc;
return ($str) unless (@_);
+ # add everything that hasn't matched to the end of the latest
+ # string in array this happen when we have 'key="=?encoded?="; key="plain"'
+ $_[-1] .= substr($str, pos $str);
+
$str = "";
while (@_) {
my ($prefix, $charset, $encoding, $enc_str, $trailing) =