+2010-04-20 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+ * ChunkStream.cs: ignore chunk extensions when reading the chunk
+ size. Fixes bug #597556.
+
2010-04-15 Gonzalo Paniagua Javier <gonzalo@novell.com>
* HttpWebRequest.cs: set content length to -1 on redirect. Reset
ThrowProtocolViolation ("Missing \\n");
try {
- if (saved.Length > 0)
- chunkSize = Int32.Parse (saved.ToString (), NumberStyles.HexNumber);
+ if (saved.Length > 0) {
+ chunkSize = Int32.Parse (RemoveChunkExtension (saved.ToString ()), NumberStyles.HexNumber);
+ }
} catch (Exception) {
ThrowProtocolViolation ("Cannot parse chunk size.");
}
chunkRead = 0;
try {
- chunkSize = Int32.Parse (saved.ToString (), NumberStyles.HexNumber);
+ chunkSize = Int32.Parse (RemoveChunkExtension (saved.ToString ()), NumberStyles.HexNumber);
} catch (Exception) {
ThrowProtocolViolation ("Cannot parse chunk size.");
}
return State.Body;
}
+ static string RemoveChunkExtension (string input)
+ {
+ int idx = input.IndexOf (';');
+ if (idx == -1)
+ return input;
+ return input.Substring (0, idx);
+ }
+
State ReadCRLF (byte [] buffer, ref int offset, int size)
{
if (!sawCR) {
if (st > 0) {
saved.Append (stString.Substring (0, saved.Length == 0? st-2: st));
st = 0;
+ if (saved.Length > 4196)
+ ThrowProtocolViolation ("Error reading trailer (too long).");
}
}
if (st < 4) {
trailerState = st;
- if (offset < size)
+ if (offset < size)
ThrowProtocolViolation ("Error reading trailer.");
return State.Trailer;