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 1
1
-- ----------------------------------------------------------------------------
2
2
-- Ada Web Server --
3
3
-- --
4
- -- Copyright (C) 2007-2019 , AdaCore --
4
+ -- Copyright (C) 2007-2021 , AdaCore --
5
5
-- --
6
6
-- This library is free software; you can redistribute it and/or modify --
7
7
-- it under terms of the GNU General Public License as published by the --
@@ -206,7 +206,30 @@ package body AWS.URL.Set is
206
206
-- -------------------
207
207
208
208
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);
210
233
I3 : constant Natural :=
211
234
Strings.Fixed.Index (PF, " /" , Strings.Backward);
212
235
begin
Original file line number Diff line number Diff line change 1
1
-- ----------------------------------------------------------------------------
2
2
-- Ada Web Server --
3
3
-- --
4
- -- Copyright (C) 2000-2017 , AdaCore --
4
+ -- Copyright (C) 2000-2021 , AdaCore --
5
5
-- --
6
6
-- This library is free software; you can redistribute it and/or modify --
7
7
-- it under terms of the GNU General Public License as published by the --
@@ -103,7 +103,7 @@ package body AWS.URL is
103
103
-- Decode --
104
104
-- ----------
105
105
106
- function Decode (Str : String) return String is
106
+ function Decode (Str : String; In_Params : Boolean ) return String is
107
107
Res : String (1 .. Str'Length);
108
108
K : Natural := 0 ;
109
109
I : Positive := Str'First;
@@ -123,7 +123,7 @@ package body AWS.URL is
123
123
Res (K) := Character'Val (Utils.Hex_Value (Str (I + 1 .. I + 2 )));
124
124
I := I + 2 ;
125
125
126
- elsif Str (I) = ' +' then
126
+ elsif In_Params and then Str (I) = ' +' then
127
127
-- A plus is used for spaces in forms value for example
128
128
Res (K) := ' ' ;
129
129
@@ -138,6 +138,11 @@ package body AWS.URL is
138
138
return Res (1 .. K);
139
139
end Decode ;
140
140
141
+ function Decode (Str : String) return String is
142
+ begin
143
+ return Decode (Str, In_Params => True);
144
+ end Decode ;
145
+
141
146
function Decode (Str : Unbounded_String) return Unbounded_String is
142
147
use Characters.Handling;
143
148
Res : Unbounded_String;
Original file line number Diff line number Diff line change 1
1
-- ----------------------------------------------------------------------------
2
2
-- Ada Web Server --
3
3
-- --
4
- -- Copyright (C) 2000-2017 , AdaCore --
4
+ -- Copyright (C) 2000-2021 , AdaCore --
5
5
-- --
6
6
-- This library is free software; you can redistribute it and/or modify --
7
7
-- it under terms of the GNU General Public License as published by the --
@@ -248,4 +248,8 @@ private
248
248
Parameters_Encoding_Set
249
249
or Strings.Maps.To_Set (" ;/:$,"" {}|\^[]`'" );
250
250
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
+
251
255
end AWS.URL ;
You can’t perform that action at this time.
0 commit comments