bug-cgicc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-cgicc] FIXED: Form fields not parsed with encoding multipart/form-d


From: bignm
Subject: [bug-cgicc] FIXED: Form fields not parsed with encoding multipart/form-data encoding
Date: Sat, 23 Jun 2012 15:15:17 -0700

Dear mailing list:

After debugging the source code of GNU cgicc version 3.2 to determine why form fields were not being parsed when an HTML INPUT type=file was present, the problem was finally traced down to the following code (fixed code displayed below):

In file Cgicc.cpp ...

CGICCNS MultipartHeader
CGICCNS Cgicc::parseHeader(const STDNS string& data)
{
    STDNS string disposition;
    disposition = extractBetween(data, "Content-Disposition: ", ";");

    STDNS string name;
    name = extractBetween(data, "name=\"", "\"");

    STDNS string filename;
    STDNS string cType;
    if (data.find("filename=") != STDNS string::npos) {
      filename = extractBetween(data, "filename=\"", "\"");
      cType = extractBetween(data, "Content-Type: ", "\r\n\r\n");
    }

  // This is hairy: Netscape and IE don't encode the filenames
  // The RFC says they should be encoded, so I will assume they are.
    filename = unescapeString(filename);

    return MultipartHeader(disposition, name, filename, cType);
}

The fix was the addition of the "if (data.find("filename=") != ... wraparound code since the check in the routine parseMIME() was getting crud data in the head.getFilename() comparison.

Now form fields are being processed properly when an HTML form uses the multipart/form-data encoding type.

As a side note, when the option --enable-debug-logging is supplied to configure the sources contrib/nph-login.cpp and contrib/nph-hello.cpp do not compile because the DEBUG logic  is missing the STDNS qualifier. The fixed code is below (which also removes the non-existing path in front of the cgicc.log filename) so now the log file appears in the current working directory.

// To use the debug logging feature, the variable gLogFile MUST be
// defined, and it _must_ be an ofstream
#if DEBUG
STDNS ofstream gLogFile ("cgicc.log", STDNS ios::app);
#endif

The fixed Cgicc.cpp & nph-hello.cpp & nph-login.cpp source files are attached.

Regards, Tom Straub


Attachment: Cgicc.cpp
Description: Binary data

Attachment: nph-hello.cpp
Description: Binary data

Attachment: nph-login.cpp
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]