[AWS] URL decode bug

Stephen Leake stephen_leake at stephe-leake.org
Thu Dec 22 23:09:19 CET 2016


(previously posted on comp.lang.ada)

I'm working on a web server that handles downloading music to my PDA,
using AWS. One of the music file names is (in part):

01 The Dance #1.mp3

The "#" is part of the file name; it does _not_ indicate a "fragment"
part of a URL.

However, if I send a properly encoded "GET" request to the AWS server:

GET .../01%20The%20Dance%20%231.mp3

it arrives in my Handle_Request subprogram with "#1.mp3" in the fragment
part of the URL (just wrong!).

Tracing through the code, the socket is read in
aws-server-http_utils.adb Get_Request_Line. That calls
aws-server-http_utils.adb Parse_Request_Line, which _decodes_ the
resource string, _then_ calls Status.Set.Request which calls
URL.Set.Parse, which puts the "#.mp3" in the fragment.

URL.Decode should be called _after_ URL.Set.Parse, not before.

On comp.lang.ada, Pascal Obry agreed this is a bug in AWS.

I tried to setup an AWS test environment using
https://github.com/AdaCore/aws, but the "templates_paser" directory is
empty, so "make setup" failed.

Attached is a patch against the AWS tarball in the GNAT GPL 2016
distribution. It passes my application test, but I was not able to run
AWS test suite.

It is not entirely backward compatible, due to the new "Decode"
parameter in AWS.URL.Set.Parse.

I started with having Parse always decode, but that doesn't work for
AWS.Client.Get, because it rebuilds the user-provided URL from a Parsed
URL; we have to specify Decode => False there, and Decode => True in
HTTP_Utils.Parse_Request_Line.

-- 
-- Stephe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: aws_decode.diff
Type: text/x-patch
Size: 12622 bytes
Desc: not available
URL: </pipermail/aws/attachments/20161222/6909171b/attachment.bin>


More information about the AWS mailing list