Chromium Code Reviews

Side by Side Diff: third_party/WebKit/Source/modules/credentialmanager/PasswordCredential.cpp

Issue 1472143003: PasswordCredential should remove entries named idName or passwordName in additionalData (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/credentialmanager/passwordcredential-fetch.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "modules/credentialmanager/PasswordCredential.h" 6 #include "modules/credentialmanager/PasswordCredential.h"
7 7
8 #include "bindings/core/v8/Dictionary.h" 8 #include "bindings/core/v8/Dictionary.h"
9 #include "bindings/core/v8/ExceptionState.h" 9 #include "bindings/core/v8/ExceptionState.h"
10 #include "core/dom/ExecutionContext.h" 10 #include "core/dom/ExecutionContext.h"
(...skipping 34 matching lines...)
45 , m_passwordName("password") 45 , m_passwordName("password")
46 { 46 {
47 } 47 }
48 48
49 PassRefPtr<EncodedFormData> PasswordCredential::encodeFormData(String& contentTy pe) const 49 PassRefPtr<EncodedFormData> PasswordCredential::encodeFormData(String& contentTy pe) const
50 { 50 {
51 if (m_additionalData.isURLSearchParams()) { 51 if (m_additionalData.isURLSearchParams()) {
52 // If |additionalData| is a 'URLSearchParams' object, build a urlencoded response. 52 // If |additionalData| is a 'URLSearchParams' object, build a urlencoded response.
53 URLSearchParams* params = URLSearchParams::create(URLSearchParamsInit()) ; 53 URLSearchParams* params = URLSearchParams::create(URLSearchParamsInit()) ;
54 URLSearchParams* additionalData = m_additionalData.getAsURLSearchParams( ); 54 URLSearchParams* additionalData = m_additionalData.getAsURLSearchParams( );
55 for (const auto& param : additionalData->params()) 55 for (const auto& param : additionalData->params()) {
56 params->append(param.first, param.second); 56 const String& name = param.first;
57 if (name != idName() && name != passwordName())
58 params->append(name, param.second);
59 }
57 params->append(idName(), id()); 60 params->append(idName(), id());
58 params->append(passwordName(), password()); 61 params->append(passwordName(), password());
59 62
60 contentType = AtomicString("application/x-www-form-urlencoded;charset=UT F-8", AtomicString::ConstructFromLiteral); 63 contentType = AtomicString("application/x-www-form-urlencoded;charset=UT F-8", AtomicString::ConstructFromLiteral);
61 64
62 return params->encodeFormData(); 65 return params->encodeFormData();
63 } 66 }
64 67
65 // Otherwise, we'll build a multipart response. 68 // Otherwise, we'll build a multipart response.
66 FormData* formData = FormData::create(nullptr); 69 FormData* formData = FormData::create(nullptr);
67 if (m_additionalData.isFormData()) { 70 if (m_additionalData.isFormData()) {
68 FormData* additionalData = m_additionalData.getAsFormData(); 71 FormData* additionalData = m_additionalData.getAsFormData();
69 for (const FormData::Entry* entry : additionalData->entries()) { 72 for (const FormData::Entry* entry : additionalData->entries()) {
73 const String& name = formData->decode(entry->name());
74 if (name == idName() || name == passwordName())
75 continue;
76
70 if (entry->blob()) 77 if (entry->blob())
71 formData->append(formData->decode(entry->name()), entry->blob(), entry->filename()); 78 formData->append(name, entry->blob(), entry->filename());
72 else 79 else
73 formData->append(formData->decode(entry->name()), formData->deco de(entry->value())); 80 formData->append(name, formData->decode(entry->value()));
74 } 81 }
75 } 82 }
76 formData->append(idName(), id()); 83 formData->append(idName(), id());
77 formData->append(passwordName(), password()); 84 formData->append(passwordName(), password());
78 85
79 RefPtr<EncodedFormData> encodedData = formData->encodeMultiPartFormData(); 86 RefPtr<EncodedFormData> encodedData = formData->encodeMultiPartFormData();
80 contentType = AtomicString("multipart/form-data; boundary=", AtomicString::C onstructFromLiteral) + encodedData->boundary().data(); 87 contentType = AtomicString("multipart/form-data; boundary=", AtomicString::C onstructFromLiteral) + encodedData->boundary().data();
81 return encodedData.release(); 88 return encodedData.release();
82 } 89 }
83 90
84 const String& PasswordCredential::password() const 91 const String& PasswordCredential::password() const
85 { 92 {
86 return static_cast<PlatformPasswordCredential*>(m_platformCredential.get())- >password(); 93 return static_cast<PlatformPasswordCredential*>(m_platformCredential.get())- >password();
87 } 94 }
88 95
89 DEFINE_TRACE(PasswordCredential) 96 DEFINE_TRACE(PasswordCredential)
90 { 97 {
91 Credential::trace(visitor); 98 Credential::trace(visitor);
92 visitor->trace(m_additionalData); 99 visitor->trace(m_additionalData);
93 } 100 }
94 101
95 } // namespace blink 102 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/credentialmanager/passwordcredential-fetch.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine