Skip to content

bug in parsing name of attachment poco c++ 1.6.0 #696

@ghost

Description

Hello!
poco c++ has code in Net/src/MailMessage.cpp file:

    std::string getFileNameFromDisp(const std::string& str)
    {
        StringTokenizer st(str, ";=", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
        StringTokenizer::Iterator it = st.begin();
        StringTokenizer::Iterator end = st.end();
        for (; it != end; ++it) { if (*it == "filename") break; }
        if (it != end)
        {
            ++it;
            if (it == end) return "";
            return *it;
        }
        return "";
    }

poco gets file name from Content-Type. So, I suposeed it should get it from "name" instead of "filename" property.
Example,
Content-Type: application/pdf; name="example.pdf" <-- see "name" is used instead of "filename".
So when poco parses attachment Poco::Net::StringPartSource::filename() returns empty string.
According RFC filename Content-Disposition should keep file name of attachment. (If I am not wrong).
Example,
Content-Disposition: attachment; filename="example.pdf"
But in fact file name usually exists in both Content-Disposition and Content-Type in different value names, "filename" and "name".

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions