rjbs / Email-MIME-ContentType

perl library for parsing content-type headers
5 stars 3 forks source link

Build method for content type #2

Closed moznion closed 4 years ago

moznion commented 10 years ago

Hello,

When this module had construction method for Content-Type which takes result of parse_content_type() as the argument, I thought that it was convenient.

Like so (Since it wrote promptly, there may be a point that something is not good); https://gist.github.com/moznion/7496660

Since this processing can be written easily, a user may actually be what to write individually. However, I thought that the way which offered unific processing was good because it doesn't make trifling difference (e.g. treatment of white space, etc...) will not be induced.

rjbs commented 10 years ago

I think this is a good idea, but am not adding it just as provided, yet. There are (awful) rules about forming content type strings, and I'd like to take some time to get it right. I'll leave this ticket open, though.

Please don't delete the gist, in case I give up on RFC compliance. ;)

Thanks!

rjbs commented 10 years ago

I'm just bringing the gist content in here. "please don't delete the gist" is silly.

sub build_content_type {
  my ($self, $content_type) = @_;

  if (!$content_type->{discrete} || !$content_type->{composite}) {
    die "! Invalid Content-Type";
  }
  my $content_type_str = "$content_type->{discrete}/$content_type->{composite}";
  for my $k (keys %{$content_type->{attributes}}) {
    my $v = $content_type->{attributes}->{$k};
    next unless $v;
    $content_type_str .= ";$k=$v";
  }
  return $content_type_str;
}
rjbs commented 10 years ago

Notes for the future:

Should be fun.

pali commented 7 years ago

Another problems:

pali commented 7 years ago

I tried to implement function build_content_type correctly according to RFC 2045 and RFC 2231. Code is in pull request https://github.com/rjbs/Email-MIME-ContentType/pull/11. So please review & test.

pali commented 6 years ago

Can somebody review or test my code in pull request? Now it is year since I opened that pull request. Is still somebody interested in it?

dxdc commented 6 years ago

second this! thanks @pali

moznion commented 4 years ago

Thank you so much for this!