View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0033680 | FPC | FCL | public | 2018-05-03 06:50 | 2018-05-07 19:51 |
Reporter | engkin | Assigned To | Michael Van Canneyt | ||
Priority | normal | Severity | minor | Reproducibility | have not tried |
Status | closed | Resolution | fixed | ||
Product Version | Product Build | ||||
Target Version | 3.2.0 | Fixed in Version | 3.1.1 | ||
Summary | 0033680: [Patch] FPHTTPClient.IndexOfHeader may give wrong value | ||||
Description | IndexOfHeader compares the header in the parameter with a part of similar length of the stored headers which, if the beginning of the stored header happen to equal the parameter, gives wrong result. | ||||
Steps To Reproduce | Add the following two headers like Accept and Accept-Language: AddHeader('Accept','text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'); AddHeader('Accept-Language','en-US,en;q=0.5'); Now both IndexOfHeader('Accept') and IndexOfHeader('Accept-Language') return the same value pointing at Accept-Language header. | ||||
Additional Information | The included patch is just a simple proposal to fix this bug by adding a colon to the header in the parameter. It also adds a space for the Cookies header, and replaces the value of an existing header with a new value. These two changes are not related to this bug. | ||||
Tags | No tags attached. | ||||
Fixed in Revision | 38910 | ||||
FPCOldBugId | |||||
FPCTarget | |||||
Attached Files |
|
|
IndexOfHeader.patch (896 bytes)
Index: fphttpclient.pp =================================================================== --- fphttpclient.pp (revision 38895) +++ fphttpclient.pp (working copy) @@ -679,7 +679,7 @@ end; if Assigned(FCookies) then begin - L:='Cookie:'; + L:='Cookie: '; For I:=0 to FCookies.Count-1 do begin If (I>0) then @@ -1303,8 +1303,9 @@ begin j:=IndexOfHeader(HTTPHeaders,Aheader); if (J<>-1) then - HTTPHeaders.Delete(j); - HTTPHeaders.Add(AHeader+': '+Avalue); + HTTPHeaders[j] := AHeader+': '+Avalue + else + HTTPHeaders.Add(AHeader+': '+Avalue); end; @@ -1315,8 +1316,8 @@ L : Integer; H : String; begin - H:=LowerCase(Aheader); - l:=Length(AHeader); + H:=LowerCase(AHeader)+':'; + l:=Length(H); Result:=HTTPHeaders.Count-1; While (Result>=0) and ((LowerCase(Copy(HTTPHeaders[Result],1,l)))<>h) do Dec(Result); |
|
project1.lpr (503 bytes) |
|
Just attached a sample project that shows the problem. |
|
Fixed, thank you very much for the patch! |
|
You are welcome! |
Date Modified | Username | Field | Change |
---|---|---|---|
2018-05-03 06:50 | engkin | New Issue | |
2018-05-03 06:50 | engkin | File Added: IndexOfHeader.patch | |
2018-05-03 09:09 | Michael Van Canneyt | Assigned To | => Michael Van Canneyt |
2018-05-03 09:09 | Michael Van Canneyt | Status | new => assigned |
2018-05-03 17:42 | engkin | File Added: project1.lpr | |
2018-05-03 17:43 | engkin | Note Added: 0108131 | |
2018-05-05 17:10 | Michael Van Canneyt | Fixed in Revision | => 38910 |
2018-05-05 17:10 | Michael Van Canneyt | Note Added: 0108158 | |
2018-05-05 17:10 | Michael Van Canneyt | Status | assigned => resolved |
2018-05-05 17:10 | Michael Van Canneyt | Fixed in Version | => 3.1.1 |
2018-05-05 17:10 | Michael Van Canneyt | Resolution | open => fixed |
2018-05-05 17:10 | Michael Van Canneyt | Target Version | => 3.2.0 |
2018-05-07 19:51 | engkin | Note Added: 0108178 | |
2018-05-07 19:51 | engkin | Status | resolved => closed |