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

Side by Side Diff: net/base/data_url.cc

Issue 5542001: Allow data URLs to trigger downloads, as they do in Firefox.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years 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 | Annotate | Revision Log
« no previous file with comments | « net/base/data_url.h ('k') | webkit/glue/weburlloader_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // NOTE: based loosely on mozilla's nsDataChannel.cpp 5 // NOTE: based loosely on mozilla's nsDataChannel.cpp
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "net/base/data_url.h" 9 #include "net/base/data_url.h"
10 10
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 charset->assign(it + sizeof(kCharsetTag)-1, comma); 53 charset->assign(it + sizeof(kCharsetTag)-1, comma);
54 } 54 }
55 } 55 }
56 56
57 // fallback to defaults if nothing specified in the URL: 57 // fallback to defaults if nothing specified in the URL:
58 if (mime_type->empty()) 58 if (mime_type->empty())
59 mime_type->assign("text/plain"); 59 mime_type->assign("text/plain");
60 if (charset->empty()) 60 if (charset->empty())
61 charset->assign("US-ASCII"); 61 charset->assign("US-ASCII");
62 62
63 // The caller may not be interested in receiving the data.
64 if (!data)
65 return true;
66
63 // Preserve spaces if dealing with text or xml input, same as mozilla: 67 // Preserve spaces if dealing with text or xml input, same as mozilla:
64 // https://bugzilla.mozilla.org/show_bug.cgi?id=138052 68 // https://bugzilla.mozilla.org/show_bug.cgi?id=138052
65 // but strip them otherwise: 69 // but strip them otherwise:
66 // https://bugzilla.mozilla.org/show_bug.cgi?id=37200 70 // https://bugzilla.mozilla.org/show_bug.cgi?id=37200
67 // (Spaces in a data URL should be escaped, which is handled below, so any 71 // (Spaces in a data URL should be escaped, which is handled below, so any
68 // spaces now are wrong. People expect to be able to enter them in the URL 72 // spaces now are wrong. People expect to be able to enter them in the URL
69 // bar for text, and it can't hurt, so we allow it.) 73 // bar for text, and it can't hurt, so we allow it.)
70 std::string temp_data = std::string(comma + 1, end); 74 std::string temp_data = std::string(comma + 1, end);
71 75
72 // For base64, we may have url-escaped whitespace which is not part 76 // For base64, we may have url-escaped whitespace which is not part
(...skipping 20 matching lines...) Expand all
93 } 97 }
94 98
95 if (base64_encoded) 99 if (base64_encoded)
96 return base::Base64Decode(temp_data, data); 100 return base::Base64Decode(temp_data, data);
97 101
98 temp_data.swap(*data); 102 temp_data.swap(*data);
99 return true; 103 return true;
100 } 104 }
101 105
102 } // namespace net 106 } // namespace net
OLDNEW
« no previous file with comments | « net/base/data_url.h ('k') | webkit/glue/weburlloader_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698