Fixed bug in RFC-2231 implementation.

This commit is contained in:
Vincent Richard 2005-04-19 11:13:50 +00:00
parent 49fee23e26
commit 95508d3495
2 changed files with 11 additions and 3 deletions

View File

@ -2,6 +2,11 @@
VERSION 0.7.1cvs VERSION 0.7.1cvs
================ ================
2005-04-19 Vincent Richard <vincent@vincent-richard.net>
* defaultParameter.cpp: fixed a bug in implementation of RFC-2231 (values
were cut if longer than maxLineLength, and no line wrapping occured).
2005-04-15 Vincent Richard <vincent@vincent-richard.net> 2005-04-15 Vincent Richard <vincent@vincent-richard.net>
* url.{hpp|cpp}, urlUtils.{hpp|cpp}: fixed a lot of bugs in URLs parsing * url.{hpp|cpp}, urlUtils.{hpp|cpp}: fixed a lot of bugs in URLs parsing

View File

@ -191,15 +191,16 @@ void defaultParameter::generate(utility::outputStream& os, const string::size_ty
// also generate a normal "7bit/us-ascii" parameter // also generate a normal "7bit/us-ascii" parameter
string::size_type pos = curLinePos; string::size_type pos = curLinePos;
if (pos + name.length() + 10 > maxLineLength) if (pos + name.length() + 10 + value.length() > maxLineLength)
{ {
os << NEW_LINE_SEQUENCE; os << NEW_LINE_SEQUENCE;
pos = NEW_LINE_SEQUENCE_LENGTH; pos = NEW_LINE_SEQUENCE_LENGTH;
} }
bool needQuoting = false; bool needQuoting = false;
string::size_type valueLength = 0;
for (string::size_type i = 0 ; (i < value.length()) && (pos < maxLineLength - 4) ; ++i) for (string::size_type i = 0 ; (i < value.length()) && (pos < maxLineLength - 4) ; ++i, ++valueLength)
{ {
switch (value[i]) switch (value[i])
{ {
@ -228,6 +229,8 @@ void defaultParameter::generate(utility::outputStream& os, const string::size_ty
} }
} }
const bool cutValue = (valueLength != value.length()); // has the value been cut?
if (needQuoting) if (needQuoting)
{ {
os << name << "=\""; os << name << "=\"";
@ -269,7 +272,7 @@ void defaultParameter::generate(utility::outputStream& os, const string::size_ty
// Also generate an extended parameter if the value contains 8-bit characters // Also generate an extended parameter if the value contains 8-bit characters
// or is too long for a single line // or is too long for a single line
if (extended || (value.length() >= (maxLineLength - name.length() + 3))) if (extended || cutValue)
{ {
os << ';'; os << ';';
++pos; ++pos;