Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(353)

Side by Side Diff: Source/core/loader/FormSubmission.cpp

Issue 311033003: Implementing mixed content for forms posting to insecure location from secure ones (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed the error when action attribute is empty. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/loader/FormSubmission.h ('k') | Source/core/loader/MixedContentChecker.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 body = String(bodyData.data(), bodyData.size()).replaceWithLiteral('+', "%20 "); 76 body = String(bodyData.data(), bodyData.size()).replaceWithLiteral('+', "%20 ");
77 77
78 StringBuilder query; 78 StringBuilder query;
79 query.append(url.query()); 79 query.append(url.query());
80 if (!query.isEmpty()) 80 if (!query.isEmpty())
81 query.append('&'); 81 query.append('&');
82 query.append(body); 82 query.append(body);
83 url.setQuery(query.toString()); 83 url.setQuery(query.toString());
84 } 84 }
85 85
86 void FormSubmission::Attributes::parseAction(const String& action) 86 void FormSubmission::Attributes::parseAction(const Document& document, const Str ing& action)
87 { 87 {
88 // FIXME: Can we parse into a KURL? 88 m_action = action.isEmpty() ? KURL() : document.completeURL(stripLeadingAndT railingHTMLSpaces(action));
89 m_action = stripLeadingAndTrailingHTMLSpaces(action);
90 } 89 }
91 90
92 AtomicString FormSubmission::Attributes::parseEncodingType(const String& type) 91 AtomicString FormSubmission::Attributes::parseEncodingType(const String& type)
93 { 92 {
94 if (equalIgnoringCase(type, "multipart/form-data")) 93 if (equalIgnoringCase(type, "multipart/form-data"))
95 return AtomicString("multipart/form-data", AtomicString::ConstructFromLi teral); 94 return AtomicString("multipart/form-data", AtomicString::ConstructFromLi teral);
96 if (equalIgnoringCase(type, "text/plain")) 95 if (equalIgnoringCase(type, "text/plain"))
97 return AtomicString("text/plain", AtomicString::ConstructFromLiteral); 96 return AtomicString("text/plain", AtomicString::ConstructFromLiteral);
98 return AtomicString("application/x-www-form-urlencoded", AtomicString::Const ructFromLiteral); 97 return AtomicString("application/x-www-form-urlencoded", AtomicString::Const ructFromLiteral);
99 } 98 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 break; 172 break;
174 } 173 }
175 } 174 }
176 } 175 }
177 176
178 FormSubmission::Attributes copiedAttributes; 177 FormSubmission::Attributes copiedAttributes;
179 copiedAttributes.copyFrom(attributes); 178 copiedAttributes.copyFrom(attributes);
180 if (submitButton) { 179 if (submitButton) {
181 AtomicString attributeValue; 180 AtomicString attributeValue;
182 if (!(attributeValue = submitButton->fastGetAttribute(formactionAttr)).i sNull()) 181 if (!(attributeValue = submitButton->fastGetAttribute(formactionAttr)).i sNull())
183 copiedAttributes.parseAction(attributeValue); 182 copiedAttributes.parseAction(form->document(), attributeValue);
184 if (!(attributeValue = submitButton->fastGetAttribute(formenctypeAttr)). isNull()) 183 if (!(attributeValue = submitButton->fastGetAttribute(formenctypeAttr)). isNull())
185 copiedAttributes.updateEncodingType(attributeValue); 184 copiedAttributes.updateEncodingType(attributeValue);
186 if (!(attributeValue = submitButton->fastGetAttribute(formmethodAttr)).i sNull()) 185 if (!(attributeValue = submitButton->fastGetAttribute(formmethodAttr)).i sNull())
187 copiedAttributes.updateMethodType(attributeValue); 186 copiedAttributes.updateMethodType(attributeValue);
188 if (!(attributeValue = submitButton->fastGetAttribute(formtargetAttr)).i sNull()) 187 if (!(attributeValue = submitButton->fastGetAttribute(formtargetAttr)).i sNull())
189 copiedAttributes.setTarget(attributeValue); 188 copiedAttributes.setTarget(attributeValue);
190 } 189 }
191 190
192 if (copiedAttributes.method() == DialogMethod) { 191 if (copiedAttributes.method() == DialogMethod) {
193 if (submitButton) 192 if (submitButton)
194 return adoptRef(new FormSubmission(submitButton->resultForDialogSubm it())); 193 return adoptRef(new FormSubmission(submitButton->resultForDialogSubm it()));
195 return adoptRef(new FormSubmission("")); 194 return adoptRef(new FormSubmission(""));
196 } 195 }
197 196
198 Document& document = form->document(); 197 Document& document = form->document();
199 KURL actionURL = document.completeURL(copiedAttributes.action().isEmpty() ? document.url().string() : copiedAttributes.action()); 198 KURL actionURL = copiedAttributes.action().isEmpty() ? document.url() : copi edAttributes.action();
200 bool isMailtoForm = actionURL.protocolIs("mailto"); 199 bool isMailtoForm = actionURL.protocolIs("mailto");
201 bool isMultiPartForm = false; 200 bool isMultiPartForm = false;
202 AtomicString encodingType = copiedAttributes.encodingType(); 201 AtomicString encodingType = copiedAttributes.encodingType();
203 202
204 if (copiedAttributes.method() == PostMethod) { 203 if (copiedAttributes.method() == PostMethod) {
205 isMultiPartForm = copiedAttributes.isMultiPartForm(); 204 isMultiPartForm = copiedAttributes.isMultiPartForm();
206 if (isMultiPartForm && isMailtoForm) { 205 if (isMultiPartForm && isMailtoForm) {
207 encodingType = AtomicString("application/x-www-form-urlencoded", Ato micString::ConstructFromLiteral); 206 encodingType = AtomicString("application/x-www-form-urlencoded", Ato micString::ConstructFromLiteral);
208 isMultiPartForm = false; 207 isMultiPartForm = false;
209 } 208 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 frameRequest.resourceRequest().setHTTPContentType(m_contentType); 272 frameRequest.resourceRequest().setHTTPContentType(m_contentType);
274 else 273 else
275 frameRequest.resourceRequest().setHTTPContentType(m_contentType + "; boundary=" + m_boundary); 274 frameRequest.resourceRequest().setHTTPContentType(m_contentType + "; boundary=" + m_boundary);
276 } 275 }
277 276
278 frameRequest.resourceRequest().setURL(requestURL()); 277 frameRequest.resourceRequest().setURL(requestURL());
279 FrameLoader::addHTTPOriginIfNeeded(frameRequest.resourceRequest(), AtomicStr ing(m_origin)); 278 FrameLoader::addHTTPOriginIfNeeded(frameRequest.resourceRequest(), AtomicStr ing(m_origin));
280 } 279 }
281 280
282 } 281 }
OLDNEW
« no previous file with comments | « Source/core/loader/FormSubmission.h ('k') | Source/core/loader/MixedContentChecker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698