Fixed parsing when space occurs at the end of the field value.

This commit is contained in:
Vincent Richard 2006-08-25 14:36:44 +00:00
parent bcaff413ca
commit 29df79e4e5
7 changed files with 14 additions and 13 deletions

View File

@ -56,7 +56,8 @@ charset::charset(const char* name)
void charset::parse(const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
{
m_name = string(buffer.begin() + position, buffer.begin() + end);
m_name = utility::stringUtils::trim
(string(buffer.begin() + position, buffer.begin() + end));
setParsedBounds(position, end);

View File

@ -50,8 +50,8 @@ contentDisposition::contentDisposition(const contentDisposition& type)
void contentDisposition::parse(const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
{
m_name = utility::stringUtils::toLower
(string(buffer.begin() + position, buffer.begin() + end));
m_name = utility::stringUtils::trim(utility::stringUtils::toLower
(string(buffer.begin() + position, buffer.begin() + end)));
setParsedBounds(position, end);

View File

@ -77,7 +77,7 @@ const ref <const encoderFactory::registeredEncoder> encoderFactory::getEncoderBy
return (*it);
}
throw exceptions::no_encoder_available();
throw exceptions::no_encoder_available(name);
}

View File

@ -53,8 +53,8 @@ encoding::encoding(const encoding& enc)
void encoding::parse(const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
{
m_name = utility::stringUtils::toLower
(string(buffer.begin() + position, buffer.begin() + end));
m_name = utility::stringUtils::trim(utility::stringUtils::toLower
(string(buffer.begin() + position, buffer.begin() + end)));
setParsedBounds(position, end);

View File

@ -123,8 +123,8 @@ const char* charset_conv_error::name() const throw() { return "charset_conv_erro
//
no_encoder_available::~no_encoder_available() throw() {}
no_encoder_available::no_encoder_available(const exception& other)
: exception("No encoder available.", other) {}
no_encoder_available::no_encoder_available(const string& name, const exception& other)
: exception("No encoder available: '" + name + "'.", other) {}
exception* no_encoder_available::clone() const { return new no_encoder_available(*this); }
const char* no_encoder_available::name() const throw() { return "no_encoder_available"; }

View File

@ -60,9 +60,9 @@ void mediaType::parse(const string& buffer, const string::size_type position,
while (p < pend && *p != '/') ++p;
m_type = utility::stringUtils::toLower(
m_type = utility::stringUtils::trim(utility::stringUtils::toLower(
string(buffer.begin() + typeStart,
buffer.begin() + position + (p - pstart)));
buffer.begin() + position + (p - pstart))));
if (p < pend)
{
@ -70,9 +70,9 @@ void mediaType::parse(const string& buffer, const string::size_type position,
++p;
// Extract the sub-type
m_subType = utility::stringUtils::toLower(
m_subType = utility::stringUtils::trim(utility::stringUtils::toLower(
string(buffer.begin() + position + (p - pstart),
buffer.begin() + end));
buffer.begin() + end)));
}
setParsedBounds(position, end);

View File

@ -129,7 +129,7 @@ class no_encoder_available : public vmime::exception
{
public:
no_encoder_available(const exception& other = NO_EXCEPTION);
no_encoder_available(const string& name, const exception& other = NO_EXCEPTION);
~no_encoder_available() throw();
exception* clone() const;