diff --git a/ChangeLog b/ChangeLog index 51796aae..19593b2c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,11 @@ VERSION 0.7.1cvs ================ +2005-04-19 Vincent Richard + + * 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 * url.{hpp|cpp}, urlUtils.{hpp|cpp}: fixed a lot of bugs in URLs parsing diff --git a/src/defaultParameter.cpp b/src/defaultParameter.cpp index 796b4d49..d2110be2 100644 --- a/src/defaultParameter.cpp +++ b/src/defaultParameter.cpp @@ -191,15 +191,16 @@ void defaultParameter::generate(utility::outputStream& os, const string::size_ty // also generate a normal "7bit/us-ascii" parameter string::size_type pos = curLinePos; - if (pos + name.length() + 10 > maxLineLength) + if (pos + name.length() + 10 + value.length() > maxLineLength) { os << NEW_LINE_SEQUENCE; pos = NEW_LINE_SEQUENCE_LENGTH; } 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]) { @@ -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) { 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 // or is too long for a single line - if (extended || (value.length() >= (maxLineLength - name.length() + 3))) + if (extended || cutValue) { os << ';'; ++pos;