| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 #include "core/html/DOMFormData.h" | 38 #include "core/html/DOMFormData.h" |
| 39 #include "core/html/HTMLFormControlElement.h" | 39 #include "core/html/HTMLFormControlElement.h" |
| 40 #include "core/html/HTMLFormElement.h" | 40 #include "core/html/HTMLFormElement.h" |
| 41 #include "core/html/HTMLInputElement.h" | 41 #include "core/html/HTMLInputElement.h" |
| 42 #include "core/html/parser/HTMLParserIdioms.h" | 42 #include "core/html/parser/HTMLParserIdioms.h" |
| 43 #include "core/loader/FrameLoadRequest.h" | 43 #include "core/loader/FrameLoadRequest.h" |
| 44 #include "core/loader/FrameLoader.h" | 44 #include "core/loader/FrameLoader.h" |
| 45 #include "platform/network/FormData.h" | 45 #include "platform/network/FormData.h" |
| 46 #include "platform/network/FormDataBuilder.h" | 46 #include "platform/network/FormDataBuilder.h" |
| 47 #include "wtf/CurrentTime.h" | 47 #include "wtf/CurrentTime.h" |
| 48 #include "wtf/text/StringBuilder.h" |
| 48 #include "wtf/text/TextEncoding.h" | 49 #include "wtf/text/TextEncoding.h" |
| 49 | 50 |
| 50 namespace WebCore { | 51 namespace WebCore { |
| 51 | 52 |
| 52 using namespace HTMLNames; | 53 using namespace HTMLNames; |
| 53 | 54 |
| 54 static int64_t generateFormDataIdentifier() | 55 static int64_t generateFormDataIdentifier() |
| 55 { | 56 { |
| 56 // Initialize to the current time to reduce the likelihood of generating | 57 // Initialize to the current time to reduce the likelihood of generating |
| 57 // identifiers that overlap with those from past/future browser sessions. | 58 // identifiers that overlap with those from past/future browser sessions. |
| 58 static int64_t nextIdentifier = static_cast<int64_t>(currentTime() * 1000000
.0); | 59 static int64_t nextIdentifier = static_cast<int64_t>(currentTime() * 1000000
.0); |
| 59 return ++nextIdentifier; | 60 return ++nextIdentifier; |
| 60 } | 61 } |
| 61 | 62 |
| 62 static void appendMailtoPostFormDataToURL(KURL& url, const FormData& data, const
String& encodingType) | 63 static void appendMailtoPostFormDataToURL(KURL& url, const FormData& data, const
String& encodingType) |
| 63 { | 64 { |
| 64 String body = data.flattenToString(); | 65 String body = data.flattenToString(); |
| 65 | 66 |
| 66 if (equalIgnoringCase(encodingType, "text/plain")) { | 67 if (equalIgnoringCase(encodingType, "text/plain")) { |
| 67 // Convention seems to be to decode, and s/&/\r\n/. Also, spaces are enc
oded as %20. | 68 // Convention seems to be to decode, and s/&/\r\n/. Also, spaces are enc
oded as %20. |
| 68 body = decodeURLEscapeSequences(body.replaceWithLiteral('&', "\r\n").rep
lace('+', ' ') + "\r\n"); | 69 body = decodeURLEscapeSequences(body.replaceWithLiteral('&', "\r\n").rep
lace('+', ' ') + "\r\n"); |
| 69 } | 70 } |
| 70 | 71 |
| 71 Vector<char> bodyData; | 72 Vector<char> bodyData; |
| 72 bodyData.append("body=", 5); | 73 bodyData.append("body=", 5); |
| 73 FormDataBuilder::encodeStringAsFormData(bodyData, body.utf8()); | 74 FormDataBuilder::encodeStringAsFormData(bodyData, body.utf8()); |
| 74 body = String(bodyData.data(), bodyData.size()).replaceWithLiteral('+', "%20
"); | 75 body = String(bodyData.data(), bodyData.size()).replaceWithLiteral('+', "%20
"); |
| 75 | 76 |
| 76 String query = url.query(); | 77 StringBuilder query; |
| 78 query.append(url.query()); |
| 77 if (!query.isEmpty()) | 79 if (!query.isEmpty()) |
| 78 query.append('&'); | 80 query.append('&'); |
| 79 query.append(body); | 81 query.append(body); |
| 80 url.setQuery(query); | 82 url.setQuery(query.toString()); |
| 81 } | 83 } |
| 82 | 84 |
| 83 void FormSubmission::Attributes::parseAction(const String& action) | 85 void FormSubmission::Attributes::parseAction(const String& action) |
| 84 { | 86 { |
| 85 // FIXME: Can we parse into a KURL? | 87 // FIXME: Can we parse into a KURL? |
| 86 m_action = stripLeadingAndTrailingHTMLSpaces(action); | 88 m_action = stripLeadingAndTrailingHTMLSpaces(action); |
| 87 } | 89 } |
| 88 | 90 |
| 89 String FormSubmission::Attributes::parseEncodingType(const String& type) | 91 String FormSubmission::Attributes::parseEncodingType(const String& type) |
| 90 { | 92 { |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 frameRequest.resourceRequest().setHTTPContentType(m_contentType); | 272 frameRequest.resourceRequest().setHTTPContentType(m_contentType); |
| 271 else | 273 else |
| 272 frameRequest.resourceRequest().setHTTPContentType(m_contentType + ";
boundary=" + m_boundary); | 274 frameRequest.resourceRequest().setHTTPContentType(m_contentType + ";
boundary=" + m_boundary); |
| 273 } | 275 } |
| 274 | 276 |
| 275 frameRequest.resourceRequest().setURL(requestURL()); | 277 frameRequest.resourceRequest().setURL(requestURL()); |
| 276 FrameLoader::addHTTPOriginIfNeeded(frameRequest.resourceRequest(), m_origin)
; | 278 FrameLoader::addHTTPOriginIfNeeded(frameRequest.resourceRequest(), m_origin)
; |
| 277 } | 279 } |
| 278 | 280 |
| 279 } | 281 } |
| OLD | NEW |