File tree Expand file tree Collapse file tree 3 files changed +38
-6
lines changed Expand file tree Collapse file tree 3 files changed +38
-6
lines changed Original file line number Diff line number Diff line change 11-- ----------------------------------------------------------------------------
22-- Ada Web Server --
33-- --
4- -- Copyright (C) 2007-2019 , AdaCore --
4+ -- Copyright (C) 2007-2021 , AdaCore --
55-- --
66-- This library is free software; you can redistribute it and/or modify --
77-- it under terms of the GNU General Public License as published by the --
@@ -206,7 +206,30 @@ package body AWS.URL.Set is
206206 -- -------------------
207207
208208 procedure Parse_Path_File (Start : Positive) is
209- PF : constant String := Decode (URL (Start .. URL'Last));
209+
210+ function Parameters_Start return Positive;
211+ -- Get the start of the parameters if any. We need that as only
212+ -- the URL parameters must decode plus characters as spaces.
213+
214+ -- --------------------
215+ -- Parameters_Start --
216+ -- --------------------
217+
218+ function Parameters_Start return Positive is
219+ begin
220+ for K in Start .. URL'Last loop
221+ if URL (K) = ' ?' then
222+ return K;
223+ end if ;
224+ end loop ;
225+
226+ return URL'Last;
227+ end Parameters_Start ;
228+
229+ P : constant Positive := Parameters_Start;
230+ PF : constant String :=
231+ Decode (URL (Start .. P), In_Params => False)
232+ & Decode (URL (P + 1 .. URL'Last), In_Params => True);
210233 I3 : constant Natural :=
211234 Strings.Fixed.Index (PF, " /" , Strings.Backward);
212235 begin
Original file line number Diff line number Diff line change 11-- ----------------------------------------------------------------------------
22-- Ada Web Server --
33-- --
4- -- Copyright (C) 2000-2017 , AdaCore --
4+ -- Copyright (C) 2000-2021 , AdaCore --
55-- --
66-- This library is free software; you can redistribute it and/or modify --
77-- it under terms of the GNU General Public License as published by the --
@@ -103,7 +103,7 @@ package body AWS.URL is
103103 -- Decode --
104104 -- ----------
105105
106- function Decode (Str : String) return String is
106+ function Decode (Str : String; In_Params : Boolean ) return String is
107107 Res : String (1 .. Str'Length);
108108 K : Natural := 0 ;
109109 I : Positive := Str'First;
@@ -123,7 +123,7 @@ package body AWS.URL is
123123 Res (K) := Character'Val (Utils.Hex_Value (Str (I + 1 .. I + 2 )));
124124 I := I + 2 ;
125125
126- elsif Str (I) = ' +' then
126+ elsif In_Params and then Str (I) = ' +' then
127127 -- A plus is used for spaces in forms value for example
128128 Res (K) := ' ' ;
129129
@@ -138,6 +138,11 @@ package body AWS.URL is
138138 return Res (1 .. K);
139139 end Decode ;
140140
141+ function Decode (Str : String) return String is
142+ begin
143+ return Decode (Str, In_Params => True);
144+ end Decode ;
145+
141146 function Decode (Str : Unbounded_String) return Unbounded_String is
142147 use Characters.Handling;
143148 Res : Unbounded_String;
Original file line number Diff line number Diff line change 11-- ----------------------------------------------------------------------------
22-- Ada Web Server --
33-- --
4- -- Copyright (C) 2000-2017 , AdaCore --
4+ -- Copyright (C) 2000-2021 , AdaCore --
55-- --
66-- This library is free software; you can redistribute it and/or modify --
77-- it under terms of the GNU General Public License as published by the --
@@ -248,4 +248,8 @@ private
248248 Parameters_Encoding_Set
249249 or Strings.Maps.To_Set (" ;/:$,"" {}|\^[]`'" );
250250
251+ function Decode (Str : String; In_Params : Boolean) return String;
252+ -- Decode URL Str. In_Params is set to True when decoding the
253+ -- parameters URL's fragment.
254+
251255end AWS.URL ;
You can’t perform that action at this time.
0 commit comments