AdaCore / aws

AWS is a complete framework to develop Web based applications in Ada.
Other
126 stars 37 forks source link

AWS misreads comments in mime.types files. #379

Open Rombobeorn opened 1 month ago

Rombobeorn commented 1 month ago

AWS.MIME.Load is supposed to read "the common standard format used by Apache mime.types", according to the comment in aws-mime.ads. That format includes comments that programs are supposed to ignore. AWS.MIME.Load reads the comments as a content type called "#" with many associated filename suffixes.

Here's a simple reproducer:

with AWS.MIME, Ada.Text_IO;
procedure Reproducer is
   Example : constant String := "filename.is";
begin
   AWS.MIME.Load("/etc/mime.types");
   Ada.Text_IO.Put_Line('"' & Example & """ translates to """ &
                        AWS.MIME.Content_Type(Example) & """.");
end Reproducer;

Let the reproducer read the mime.types distributed with Apache HTTPD, or one of the copies distributed with AWS, or /etc/mime.types in the mailcap package in Fedora, RHEL and others, or /etc/mime.types in the media-types package in Debian. All of them contain the word "is", so the output will be:

"filename.is" translates to "#".

Correct output would be:

"filename.is" translates to "application/octet-stream".

Rombobeorn commented 1 month ago

Here's the patch I'm applying in Fedora:

https://src.fedoraproject.org/rpms/aws/blob/rawhide/f/aws-mime-types-comments.patch