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

Side by Side Diff: webkit/browser/appcache/manifest_parser.cc

Issue 276093003: appcache content-type check (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // This is a port of ManifestParser.cc from WebKit/WebCore/loader/appcache. 5 // This is a port of ManifestParser.cc from WebKit/WebCore/loader/appcache.
6 6
7 /* 7 /*
8 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 8 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 RETURN, 68 RETURN,
69 EXECUTE, 69 EXECUTE,
70 UNKNOWN_VERB, 70 UNKNOWN_VERB,
71 }; 71 };
72 72
73 Manifest::Manifest() : online_whitelist_all(false) {} 73 Manifest::Manifest() : online_whitelist_all(false) {}
74 74
75 Manifest::~Manifest() {} 75 Manifest::~Manifest() {}
76 76
77 bool ParseManifest(const GURL& manifest_url, const char* data, int length, 77 bool ParseManifest(const GURL& manifest_url, const char* data, int length,
78 Manifest& manifest) { 78 bool allow_intercepts, Manifest& manifest) {
79 // This is an implementation of the parsing algorithm specified in 79 // This is an implementation of the parsing algorithm specified in
80 // the HTML5 offline web application docs: 80 // the HTML5 offline web application docs:
81 // http://www.w3.org/TR/html5/offline.html 81 // http://www.w3.org/TR/html5/offline.html
82 // Do not modify it without consulting those docs. 82 // Do not modify it without consulting those docs.
83 // Though you might be tempted to convert these wstrings to UTF-8 or 83 // Though you might be tempted to convert these wstrings to UTF-8 or
84 // base::string16, this implementation seems simpler given the constraints. 84 // base::string16, this implementation seems simpler given the constraints.
85 85
86 const wchar_t kSignature[] = L"CACHE MANIFEST"; 86 const wchar_t kSignature[] = L"CACHE MANIFEST";
87 const size_t kSignatureLength = arraysize(kSignature) - 1; 87 const size_t kSignatureLength = arraysize(kSignature) - 1;
88 const wchar_t kChromiumSignature[] = L"CHROMIUM CACHE MANIFEST"; 88 const wchar_t kChromiumSignature[] = L"CHROMIUM CACHE MANIFEST";
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 // condition is enforced in AppCacheUpdateJob. 211 // condition is enforced in AppCacheUpdateJob.
212 212
213 if (mode == EXPLICIT) { 213 if (mode == EXPLICIT) {
214 manifest.explicit_urls.insert(url.spec()); 214 manifest.explicit_urls.insert(url.spec());
215 } else { 215 } else {
216 bool is_pattern = HasPatternMatchingAnnotation(line_p, line_end); 216 bool is_pattern = HasPatternMatchingAnnotation(line_p, line_end);
217 manifest.online_whitelist_namespaces.push_back( 217 manifest.online_whitelist_namespaces.push_back(
218 Namespace(NETWORK_NAMESPACE, url, GURL(), is_pattern)); 218 Namespace(NETWORK_NAMESPACE, url, GURL(), is_pattern));
219 } 219 }
220 } else if (mode == INTERCEPT) { 220 } else if (mode == INTERCEPT) {
221 if (!allow_intercepts)
222 continue;
223
221 // Lines of the form, 224 // Lines of the form,
222 // <urlnamespace> <intercept_type> <targeturl> 225 // <urlnamespace> <intercept_type> <targeturl>
223 const wchar_t* line_p = line.c_str(); 226 const wchar_t* line_p = line.c_str();
224 const wchar_t* line_end = line_p + line.length(); 227 const wchar_t* line_end = line_p + line.length();
225 228
226 // Look for first whitespace separating the url namespace from 229 // Look for first whitespace separating the url namespace from
227 // the intercept type. 230 // the intercept type.
228 while (line_p < line_end && *line_p != '\t' && *line_p != ' ') 231 while (line_p < line_end && *line_p != '\t' && *line_p != ' ')
229 ++line_p; 232 ++line_p;
230 233
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 fallback_url, is_pattern)); 366 fallback_url, is_pattern));
364 } else { 367 } else {
365 NOTREACHED(); 368 NOTREACHED();
366 } 369 }
367 } 370 }
368 371
369 return true; 372 return true;
370 } 373 }
371 374
372 } // namespace appcache 375 } // namespace appcache
OLDNEW
« webkit/browser/appcache/manifest_parser.h ('K') | « webkit/browser/appcache/manifest_parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698