Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes
nsFSMultipartFormData Class Reference

Handle multipart/form-data encoding, which does files as well as normal inputs. More...

Inheritance diagram for nsFSMultipartFormData:
Inheritance graph
[legend]
Collaboration diagram for nsFSMultipartFormData:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsFSMultipartFormData (const nsACString &aCharset, nsISaveAsCharset *aEncoder, nsIFormProcessor *aFormProcessor, PRInt32 aBidiOptions)
virtual ~nsFSMultipartFormData ()
virtual
NS_DECL_ISUPPORTS_INHERITED
nsresult 
AddNameValuePair (nsIDOMHTMLElement *aSource, const nsAString &aName, const nsAString &aValue)
 Submit a name/value pair.
virtual nsresult AddNameFilePair (nsIDOMHTMLElement *aSource, const nsAString &aName, const nsAString &aFilename, nsIInputStream *aStream, const nsACString &aContentType, PRBool aMoreFilesToCome)
 Submit a name/file pair.
virtual PRBool AcceptsFiles () const
 Find out whether or not this form submission accepts files.
NS_IMETHOD Init ()
 Called to initialize the submission.
virtual NS_DECL_ISUPPORTS nsresult SubmitTo (nsIURI *aActionURI, const nsAString &aTarget, nsIContent *aSource, nsPresContext *aPresContext, nsIDocShell **aDocShell, nsIRequest **aRequest)
 Call to perform the submission.

Static Public Member Functions

static void GetSubmitCharset (nsGenericHTMLElement *aForm, PRUint8 aCtrlsModAtSubmit, nsACString &aCharset)
 Get the submit charset for a form (suitable to pass in to the constructor).
static nsresult GetEncoder (nsGenericHTMLElement *aForm, nsPresContext *aPresContext, const nsACString &aCharset, nsISaveAsCharset **aEncoder)
 Get the encoder for a form (suitable to pass in to the constructor).
static void GetEnumAttr (nsGenericHTMLElement *aForm, nsIAtom *aAtom, PRInt32 *aValue)
 Get an attribute of a form as int, provided that it is an enumerated value.

Protected Member Functions

NS_IMETHOD GetEncodedSubmission (nsIURI *aURI, nsIInputStream **aPostDataStream)
 Given a URI and the current submission, create the final URI and data stream that will be submitted.
nsresult AddPostDataStream ()
 Roll up the data we have so far and add it to the multiplexed data stream.
nsresult ProcessAndEncode (nsIDOMHTMLElement *aSource, const nsAString &aName, const nsAString &aValue, nsCString &aProcessedName, nsCString &aProcessedValue)
 Call ProcessValue() and EncodeVal() on name and value.
nsresult ProcessValue (nsIDOMHTMLElement *aSource, const nsAString &aName, const nsAString &aValue, nsAString &aResult)
 Call to have the form processor listen in when a name/value pair is found to be submitted.
nsresult EncodeVal (const nsAString &aStr, nsACString &aResult)
 Encode a Unicode string to bytes using the encoder (or just copy the input if there is no encoder).
nsresult UnicodeToNewBytes (const nsAString &aStr, nsISaveAsCharset *aEncoder, nsACString &aOut)
 Encode a Unicode string to bytes using an encoder.

Protected Attributes

nsCString mCharset
 The name of the encoder charset.
nsCOMPtr< nsISaveAsCharsetmEncoder
 The encoder that will encode Unicode names and values into bytes to be sent over the wire (usually a charset transformation)
nsCOMPtr< nsIFormProcessormFormProcessor
 A form processor who can listen to values.
PRInt32 mBidiOptions
 The BIDI options flags for the current pres context.

Private Attributes

PRBool mBackwardsCompatibleSubmit
 Get whether we are supposed to be doing backwards compatible submit, which causes us to leave off the mandatory Content-Transfer-Encoding header.
nsCOMPtr< nsIMultiplexInputStreammPostDataStream
 The post data stream as it is so far.
nsCString mPostDataChunk
 The current string chunk.
nsCString mBoundary
 The boundary string to use after each "part" (the boundary that marks the end of a value).

Detailed Description

Handle multipart/form-data encoding, which does files as well as normal inputs.

This always does POST.

Definition at line 601 of file nsFormSubmission.cpp.


Constructor & Destructor Documentation

nsFSMultipartFormData::nsFSMultipartFormData ( const nsACString &  aCharset,
nsISaveAsCharset aEncoder,
nsIFormProcessor aFormProcessor,
PRInt32  aBidiOptions 
)
Parameters:
aCharsetthe charset of the form as a string
aEncoderan encoder that will encode Unicode names and values into bytes to be sent over the wire (usually a charset transformation)
aFormProcessora form processor who can listen to
aBidiOptionsthe BIDI options flags for the current pres context

Definition at line 705 of file nsFormSubmission.cpp.

    : nsFormSubmission(aCharset, aEncoder, aFormProcessor, aBidiOptions)
{
  // XXX I can't *believe* we have a pref for this.  ifdef, anyone?
  mBackwardsCompatibleSubmit =
    nsContentUtils::GetBoolPref("browser.forms.submit.backwards_compatible");
}

Here is the call graph for this function:

virtual nsFSMultipartFormData::~nsFSMultipartFormData ( ) [inline, virtual]

Definition at line 615 of file nsFormSubmission.cpp.

{ }

Member Function Documentation

virtual PRBool nsFSMultipartFormData::AcceptsFiles ( ) const [inline, virtual]

Find out whether or not this form submission accepts files.

Parameters:
aAcceptsFilesthe boolean output

Implements nsIFormSubmission.

Definition at line 629 of file nsFormSubmission.cpp.

  {
    return PR_TRUE;
  }
nsresult nsFSMultipartFormData::AddNameFilePair ( nsIDOMHTMLElement aSource,
const nsAString &  aName,
const nsAString &  aFilename,
nsIInputStream aStream,
const nsACString &  aContentType,
PRBool  aMoreFilesToCome 
) [virtual]

Submit a name/file pair.

Parameters:
aSourcethe control sending the parameter
aNamethe name of the parameter
aFilenamethe name of the file (pass null to provide no name)
aStreamthe stream containing the file data to be sent
aContentTypethe content-type of the file data being sent
aMoreFilesToCometrue if another name/file pair with the same name will be sent soon

Implements nsIFormSubmission.

Definition at line 785 of file nsFormSubmission.cpp.

{
  nsCAutoString nameStr;
  nsCAutoString filenameStr;
  nsresult rv = ProcessAndEncode(aSource, aName, aFilename, nameStr, filenameStr);
  NS_ENSURE_SUCCESS(rv, rv);

  //
  // Make MIME block for name/value pair
  //
  // more appropriate than always using binary?
  mPostDataChunk += NS_LITERAL_CSTRING("--") + mBoundary
                 + NS_LITERAL_CSTRING(CRLF);
  if (!mBackwardsCompatibleSubmit) {
    // XXX Is there any way to tell when "8bit" or "7bit" etc may be
    mPostDataChunk +=
          NS_LITERAL_CSTRING("Content-Transfer-Encoding: binary" CRLF);
  }
  // XXX: name/filename parameter should be encoded per RFC 2231
  // RFC 2388 specifies that RFC 2047 be used, but I think it's not 
  // consistent with the MIME standard.
  mPostDataChunk +=
         NS_LITERAL_CSTRING("Content-Disposition: form-data; name=\"")
       + nameStr + NS_LITERAL_CSTRING("\"; filename=\"")
       + filenameStr + NS_LITERAL_CSTRING("\"" CRLF)
       + NS_LITERAL_CSTRING("Content-Type: ") + aContentType
       + NS_LITERAL_CSTRING(CRLF CRLF);

  //
  // Add the file to the stream
  //
  if (aStream) {
    // We need to dump the data up to this point into the POST data stream here,
    // since we're about to add the file input stream
    AddPostDataStream();

    mPostDataStream->AppendStream(aStream);
  }

  //
  // CRLF after file
  //
  mPostDataChunk.AppendLiteral(CRLF);

  return NS_OK;
}

Here is the call graph for this function:

nsresult nsFSMultipartFormData::AddNameValuePair ( nsIDOMHTMLElement aSource,
const nsAString &  aName,
const nsAString &  aValue 
) [virtual]

Submit a name/value pair.

Parameters:
aSourcethe control sending the parameter
aNamethe name of the parameter
aValuethe value of the parameter

Implements nsIFormSubmission.

Definition at line 760 of file nsFormSubmission.cpp.

{
  nsCAutoString nameStr;
  nsCString valueStr;
  nsresult rv = ProcessAndEncode(aSource, aName, aValue, nameStr, valueStr);
  NS_ENSURE_SUCCESS(rv, rv);

  //
  // Make MIME block for name/value pair
  //
  // XXX: name parameter should be encoded per RFC 2231
  // RFC 2388 specifies that RFC 2047 be used, but I think it's not 
  // consistent with MIME standard.
  mPostDataChunk += NS_LITERAL_CSTRING("--") + mBoundary
                 + NS_LITERAL_CSTRING(CRLF)
                 + NS_LITERAL_CSTRING("Content-Disposition: form-data; name=\"")
                 + nameStr + NS_LITERAL_CSTRING("\"" CRLF CRLF)
                 + valueStr + NS_LITERAL_CSTRING(CRLF);

  return NS_OK;
}

Here is the call graph for this function:

Roll up the data we have so far and add it to the multiplexed data stream.

Definition at line 905 of file nsFormSubmission.cpp.

{
  nsresult rv = NS_OK;
  
  nsCOMPtr<nsIInputStream> postDataChunkStream;
  rv = NS_NewCStringInputStream(getter_AddRefs(postDataChunkStream),
                                mPostDataChunk);
  NS_ASSERTION(postDataChunkStream, "Could not open a stream for POST!");
  if (postDataChunkStream) {
    mPostDataStream->AppendStream(postDataChunkStream);
  }

  mPostDataChunk.Truncate();

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsFormSubmission::EncodeVal ( const nsAString &  aStr,
nsACString &  aResult 
) [protected, inherited]

Encode a Unicode string to bytes using the encoder (or just copy the input if there is no encoder).

Parameters:
aStrthe string to encode
aResultthe encoded string [OUT]
Exceptions:
anerror if UnicodeToNewBytes fails

Definition at line 1423 of file nsFormSubmission.cpp.

{
  NS_ASSERTION(mEncoder, "Encoder not available. Losing data !");
  if (mEncoder)
    return UnicodeToNewBytes(aStr, mEncoder, aOut);

  // fall back to UTF-8
  CopyUTF16toUTF8(aStr, aOut);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsFSMultipartFormData::GetEncodedSubmission ( nsIURI aURI,
nsIInputStream **  aPostDataStream 
) [protected, virtual]

Given a URI and the current submission, create the final URI and data stream that will be submitted.

Subclasses must implement this.

Parameters:
aURIthe URI being submitted to [INOUT]
aPostDataStreama data stream for POST data [OUT]

Implements nsFormSubmission.

Definition at line 867 of file nsFormSubmission.cpp.

{
  nsresult rv;

  //
  // Finish data
  //
  mPostDataChunk += NS_LITERAL_CSTRING("--") + mBoundary
                  + NS_LITERAL_CSTRING("--" CRLF);

  //
  // Add final data input stream
  //
  AddPostDataStream();

  //
  // Make header
  //
  nsCOMPtr<nsIMIMEInputStream> mimeStream
    = do_CreateInstance("@mozilla.org/network/mime-input-stream;1", &rv);
  NS_ENSURE_SUCCESS(rv, rv);

  nsCAutoString boundaryHeaderValue(
    NS_LITERAL_CSTRING("multipart/form-data; boundary=") + mBoundary);

  mimeStream->AddHeader("Content-Type", boundaryHeaderValue.get());
  mimeStream->SetAddContentLength(PR_TRUE);
  mimeStream->SetData(mPostDataStream);

  *aPostDataStream = mimeStream;

  NS_ADDREF(*aPostDataStream);

  return NS_OK;
}

Here is the call graph for this function:

nsresult nsFormSubmission::GetEncoder ( nsGenericHTMLElement aForm,
nsPresContext aPresContext,
const nsACString &  aCharset,
nsISaveAsCharset **  aEncoder 
) [static, inherited]

Get the encoder for a form (suitable to pass in to the constructor).

Parameters:
aFormthe form in question
aPresContextthe pres context in which we are submitting
aCharsetthe charset of the form
aEncoderthe returned encoder [OUT]

Definition at line 1309 of file nsFormSubmission.cpp.

{
  *aEncoder = nsnull;
  nsresult rv = NS_OK;

  nsCAutoString charset(aCharset);
  // canonical name is passed so that we just have to check against
  // *our* canonical names listed in charsetaliases.properties
  if (charset.EqualsLiteral("ISO-8859-1")) {
    charset.AssignLiteral("windows-1252");
  }

  // use UTF-8 for UTF-16* and UTF-32* (per WHATWG and existing practice of
  // MS IE/Opera). 
  if (StringBeginsWith(charset, NS_LITERAL_CSTRING("UTF-16")) || 
      StringBeginsWith(charset, NS_LITERAL_CSTRING("UTF-32"))) {
    charset.AssignLiteral("UTF-8");
  }

  rv = CallCreateInstance( NS_SAVEASCHARSET_CONTRACTID, aEncoder);
  NS_ASSERTION(NS_SUCCEEDED(rv), "create nsISaveAsCharset failed");
  NS_ENSURE_SUCCESS(rv, rv);

  rv = (*aEncoder)->Init(charset.get(),
                         (nsISaveAsCharset::attr_EntityAfterCharsetConv + 
                          nsISaveAsCharset::attr_FallbackDecimalNCR),
                         0);
  NS_ASSERTION(NS_SUCCEEDED(rv), "initialize nsISaveAsCharset failed");
  NS_ENSURE_SUCCESS(rv, rv);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsFormSubmission::GetEnumAttr ( nsGenericHTMLElement aForm,
nsIAtom aAtom,
PRInt32 aValue 
) [static, inherited]

Get an attribute of a form as int, provided that it is an enumerated value.

Parameters:
aFormthe form in question
aAtomthe attribute (for example, nsHTMLAtoms::enctype) to get
aValuethe result (will not be set at all if the attribute does not exist on the form, so make sure you provide a default value.) [OUT]

Definition at line 1413 of file nsFormSubmission.cpp.

{
  const nsAttrValue* value = aContent->GetParsedAttr(atom);
  if (value && value->Type() == nsAttrValue::eEnum) {
    *aValue = value->GetEnumValue();
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsFormSubmission::GetSubmitCharset ( nsGenericHTMLElement aForm,
PRUint8  aCtrlsModAtSubmit,
nsACString &  aCharset 
) [static, inherited]

Get the submit charset for a form (suitable to pass in to the constructor).

Parameters:
aFormthe form in question
aCtrlsModAtSubmitBIDI controls text mode. Unused in non-BIDI builds.
aCharsetthe returned charset [OUT]

Definition at line 1238 of file nsFormSubmission.cpp.

{
  oCharset.AssignLiteral("UTF-8"); // default to utf-8

  nsresult rv = NS_OK;
  nsAutoString acceptCharsetValue;
  aForm->GetAttr(kNameSpaceID_None, nsHTMLAtoms::acceptcharset,
                 acceptCharsetValue);

  PRInt32 charsetLen = acceptCharsetValue.Length();
  if (charsetLen > 0) {
    PRInt32 offset=0;
    PRInt32 spPos=0;
    // get charset from charsets one by one
    nsCOMPtr<nsICharsetAlias> calias(do_GetService(kCharsetAliasCID, &rv));
    if (NS_FAILED(rv)) {
      return;
    }
    if (calias) {
      do {
        spPos = acceptCharsetValue.FindChar(PRUnichar(' '), offset);
        PRInt32 cnt = ((-1==spPos)?(charsetLen-offset):(spPos-offset));
        if (cnt > 0) {
          nsAutoString uCharset;
          acceptCharsetValue.Mid(uCharset, offset, cnt);

          if (NS_SUCCEEDED(calias->
                           GetPreferred(NS_LossyConvertUTF16toASCII(uCharset),
                                        oCharset)))
            return;
        }
        offset = spPos + 1;
      } while (spPos != -1);
    }
  }
  // if there are no accept-charset or all the charset are not supported
  // Get the charset from document
  nsIDocument* doc = aForm->GetDocument();
  if (doc) {
    oCharset = doc->GetDocumentCharacterSet();
  }

  if (aCtrlsModAtSubmit==IBMBIDI_CONTROLSTEXTMODE_VISUAL
     && oCharset.Equals(NS_LITERAL_CSTRING("windows-1256"),
                        nsCaseInsensitiveCStringComparator())) {
//Mohamed
    oCharset.AssignLiteral("IBM864");
  }
  else if (aCtrlsModAtSubmit==IBMBIDI_CONTROLSTEXTMODE_LOGICAL
          && oCharset.Equals(NS_LITERAL_CSTRING("IBM864"),
                             nsCaseInsensitiveCStringComparator())) {
    oCharset.AssignLiteral("IBM864i");
  }
  else if (aCtrlsModAtSubmit==IBMBIDI_CONTROLSTEXTMODE_VISUAL
          && oCharset.Equals(NS_LITERAL_CSTRING("ISO-8859-6"),
                             nsCaseInsensitiveCStringComparator())) {
    oCharset.AssignLiteral("IBM864");
  }
  else if (aCtrlsModAtSubmit==IBMBIDI_CONTROLSTEXTMODE_VISUAL
          && oCharset.Equals(NS_LITERAL_CSTRING("UTF-8"),
                             nsCaseInsensitiveCStringComparator())) {
    oCharset.AssignLiteral("IBM864");
  }

}

Here is the call graph for this function:

Here is the caller graph for this function:

Called to initialize the submission.

Perform any initialization that may fail here. Subclasses must implement this.

Implements nsFormSubmission.

Definition at line 841 of file nsFormSubmission.cpp.

{
  nsresult rv;

  //
  // Create the POST stream
  //
  mPostDataStream =
    do_CreateInstance("@mozilla.org/io/multiplex-input-stream;1", &rv);
  NS_ENSURE_SUCCESS(rv, rv);
  if (!mPostDataStream) {
    return NS_ERROR_OUT_OF_MEMORY;
  }

  //
  // Build boundary
  //
  mBoundary.AssignLiteral("---------------------------");
  mBoundary.AppendInt(rand());
  mBoundary.AppendInt(rand());
  mBoundary.AppendInt(rand());

  return NS_OK;
}

Here is the call graph for this function:

nsresult nsFSMultipartFormData::ProcessAndEncode ( nsIDOMHTMLElement aSource,
const nsAString &  aName,
const nsAString &  aValue,
nsCString aProcessedName,
nsCString aProcessedValue 
) [protected]

Call ProcessValue() and EncodeVal() on name and value.

Parameters:
aSourcethe source of the name/value pair
aNamethe name to be sent
aValuethe value to be sent
aProcessedNamethe name, after being encoded [OUT]
aProcessedValuethe value, after being processed / encoded [OUT]
Exceptions:
NS_ERROR_OUT_OF_MEMORYif out of memory

Definition at line 717 of file nsFormSubmission.cpp.

{
  //
  // Let external code process (and possibly change) value
  //
  nsAutoString processedValue;
  nsresult rv = ProcessValue(aSource, aName, aValue, processedValue);

  //
  // Get value
  //
  nsCAutoString encodedVal;
  if (NS_SUCCEEDED(rv)) {
    rv = EncodeVal(processedValue, encodedVal);
  } else {
    rv = EncodeVal(aValue, encodedVal);
  }
  NS_ENSURE_SUCCESS(rv, rv);

  //
  // Get name
  //
  rv  = EncodeVal(aName, aProcessedName);
  NS_ENSURE_SUCCESS(rv, rv);


  //
  // Convert linebreaks in value
  //
  aProcessedValue.Adopt(nsLinebreakConverter::ConvertLineBreaks(encodedVal.get(),
                        nsLinebreakConverter::eLinebreakAny,
                        nsLinebreakConverter::eLinebreakNet));
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsFormSubmission::ProcessValue ( nsIDOMHTMLElement aSource,
const nsAString &  aName,
const nsAString &  aValue,
nsAString &  aResult 
) [protected, inherited]

Call to have the form processor listen in when a name/value pair is found to be submitted.

Parameters:
aSourcethe HTML element the name/value is associated with
aNamethe name that will be submitted
aValuethe value that will be submitted
theprocessed value that will be sent to the server. [OUT]

Definition at line 1435 of file nsFormSubmission.cpp.

{
  // Hijack _charset_ (hidden inputs only) for internationalization (bug 18643)
  if (aName.EqualsLiteral("_charset_")) {
    nsCOMPtr<nsIFormControl> formControl = do_QueryInterface(aSource);
    if (formControl && formControl->GetType() == NS_FORM_INPUT_HIDDEN) {
        CopyASCIItoUTF16(mCharset, aResult);
        return NS_OK;
    }
  }

  nsresult rv = NS_OK;
  aResult = aValue;
  if (mFormProcessor) {
    rv = mFormProcessor->ProcessValue(aSource, aName, aResult);
    NS_ASSERTION(NS_SUCCEEDED(rv), "Unable to Notify form process observer");
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsFormSubmission::SubmitTo ( nsIURI aActionURL,
const nsAString &  aTarget,
nsIContent aSource,
nsPresContext aPresContext,
nsIDocShell **  aDocShell,
nsIRequest **  aRequest 
) [virtual, inherited]

Call to perform the submission.

Parameters:
aActionURLthe URL to submit to (may be modified with GET contents)
aTargetthe target window
aSourcethe element responsible for the submission (for web shell)
aPresContextthe presentation context
aDocShell(out param) the DocShell in which the submission was loaded
aRequest(out param) the Request for the submission

Implements nsIFormSubmission.

Definition at line 1209 of file nsFormSubmission.cpp.

{
  nsresult rv;

  //
  // Finish encoding (get post data stream and URI)
  //
  nsCOMPtr<nsIInputStream> postDataStream;
  rv = GetEncodedSubmission(aActionURI, getter_AddRefs(postDataStream));
  NS_ENSURE_SUCCESS(rv, rv);

  //
  // Actually submit the data
  //
  nsILinkHandler *handler = aPresContext->GetLinkHandler();
  NS_ENSURE_TRUE(handler, NS_ERROR_FAILURE);

  return handler->OnLinkClickSync(aSource, eLinkVerb_Replace,
                                  aActionURI,
                                  PromiseFlatString(aTarget).get(),
                                  postDataStream, nsnull,
                                  aDocShell, aRequest);
}

Here is the call graph for this function:

nsresult nsFormSubmission::UnicodeToNewBytes ( const nsAString &  aStr,
nsISaveAsCharset aEncoder,
nsACString &  aOut 
) [protected, inherited]

Encode a Unicode string to bytes using an encoder.

(Used by EncodeVal)

Parameters:
aStrthe string to encode
aEncoderthe encoder to encode the bytes with (cannot be null)
aOutthe encoded string [OUT]
Exceptions:
anerror if the encoder fails

Definition at line 1347 of file nsFormSubmission.cpp.

{
  PRUint8 ctrlsModAtSubmit = GET_BIDI_OPTION_CONTROLSTEXTMODE(mBidiOptions);
  PRUint8 textDirAtSubmit = GET_BIDI_OPTION_DIRECTION(mBidiOptions);
  //ahmed 15-1
  nsAutoString newBuffer;
  //This condition handle the RTL,LTR for a logical file
  if (ctrlsModAtSubmit == IBMBIDI_CONTROLSTEXTMODE_VISUAL
     && mCharset.Equals(NS_LITERAL_CSTRING("windows-1256"),
                        nsCaseInsensitiveCStringComparator())) {
    Conv_06_FE_WithReverse(nsString(aStr),
                           newBuffer,
                           textDirAtSubmit);
  }
  else if (ctrlsModAtSubmit == IBMBIDI_CONTROLSTEXTMODE_LOGICAL
          && mCharset.Equals(NS_LITERAL_CSTRING("IBM864"),
                             nsCaseInsensitiveCStringComparator())) {
    //For 864 file, When it is logical, if LTR then only convert
    //If RTL will mak a reverse for the buffer
    Conv_FE_06(nsString(aStr), newBuffer);
    if (textDirAtSubmit == 2) { //RTL
    //Now we need to reverse the Buffer, it is by searching the buffer
      PRInt32 len = newBuffer.Length();
      PRUint32 z = 0;
      nsAutoString temp;
      temp.SetLength(len);
      while (--len >= 0)
        temp.SetCharAt(newBuffer.CharAt(len), z++);
      newBuffer = temp;
    }
  }
  else if (ctrlsModAtSubmit == IBMBIDI_CONTROLSTEXTMODE_VISUAL
          && mCharset.Equals(NS_LITERAL_CSTRING("IBM864"),
                             nsCaseInsensitiveCStringComparator())
                  && textDirAtSubmit == IBMBIDI_TEXTDIRECTION_RTL) {

    Conv_FE_06(nsString(aStr), newBuffer);
    //Now we need to reverse the Buffer, it is by searching the buffer
    PRInt32 len = newBuffer.Length();
    PRUint32 z = 0;
    nsAutoString temp;
    temp.SetLength(len);
    while (--len >= 0)
      temp.SetCharAt(newBuffer.CharAt(len), z++);
    newBuffer = temp;
  }
  else {
    newBuffer = aStr;
  }

  nsXPIDLCString res;
  if (!newBuffer.IsEmpty()) {
    aOut.Truncate();
    nsresult rv = aEncoder->Convert(newBuffer.get(), getter_Copies(res));
    NS_ENSURE_SUCCESS(rv, rv);
  }

  aOut = res;
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Get whether we are supposed to be doing backwards compatible submit, which causes us to leave off the mandatory Content-Transfer-Encoding header.

This used to cause Bad Things, including server crashes.

It is hoped that we can get rid of this at some point, but that will take a lot of testing or some other browsers that send the header and have not had problems.

Definition at line 672 of file nsFormSubmission.cpp.

PRInt32 nsFormSubmission::mBidiOptions [protected, inherited]

The BIDI options flags for the current pres context.

Definition at line 176 of file nsFormSubmission.cpp.

The boundary string to use after each "part" (the boundary that marks the end of a value).

This is computed randomly and is different for each submission.

Definition at line 695 of file nsFormSubmission.cpp.

nsCString nsFormSubmission::mCharset [protected, inherited]

The name of the encoder charset.

Definition at line 168 of file nsFormSubmission.cpp.

The encoder that will encode Unicode names and values into bytes to be sent over the wire (usually a charset transformation)

Definition at line 172 of file nsFormSubmission.cpp.

A form processor who can listen to values.

Definition at line 174 of file nsFormSubmission.cpp.

The current string chunk.

When a file is hit, the string chunk gets wrapped up into an input stream and put into mPostDataStream so that the file input stream can then be appended and everything is in the right order. Then the string chunk gets appended to again as we process more name/value pairs.

Definition at line 688 of file nsFormSubmission.cpp.

The post data stream as it is so far.

This is a collection of smaller chunks--string streams and file streams interleaved to make one big POST stream.

Definition at line 679 of file nsFormSubmission.cpp.


The documentation for this class was generated from the following file: