summaryrefslogtreecommitdiff
path: root/Source/WebCore/loader/appcache/ManifestParser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/loader/appcache/ManifestParser.cpp')
-rw-r--r--Source/WebCore/loader/appcache/ManifestParser.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/Source/WebCore/loader/appcache/ManifestParser.cpp b/Source/WebCore/loader/appcache/ManifestParser.cpp
index a47aa150e..5c151359d 100644
--- a/Source/WebCore/loader/appcache/ManifestParser.cpp
+++ b/Source/WebCore/loader/appcache/ManifestParser.cpp
@@ -28,6 +28,7 @@
#include "TextResourceDecoder.h"
#include "URL.h"
+#include <wtf/text/StringView.h>
#include <wtf/unicode/CharacterNames.h>
namespace WebCore {
@@ -43,9 +44,7 @@ bool parseManifest(const URL& manifestURL, const char* data, int length, Manifes
Mode mode = Explicit;
- RefPtr<TextResourceDecoder> decoder = TextResourceDecoder::create("text/cache-manifest", "UTF-8");
- String s = decoder->decode(data, length);
- s.append(decoder->flush());
+ String s = TextResourceDecoder::create("text/cache-manifest", "UTF-8")->decodeAndFlush(data, length);
// Look for the magic signature: "^\xFEFF?CACHE MANIFEST[ \t]?" (the BOM is removed by TextResourceDecoder).
// Example: "CACHE MANIFEST #comment" is a valid signature.
@@ -53,8 +52,10 @@ bool parseManifest(const URL& manifestURL, const char* data, int length, Manifes
if (!s.startsWith("CACHE MANIFEST"))
return false;
- const UChar* end = s.deprecatedCharacters() + s.length();
- const UChar* p = s.deprecatedCharacters() + 14; // "CACHE MANIFEST" is 14 characters.
+ StringView manifestAfterSignature = StringView(s).substring(14); // "CACHE MANIFEST" is 14 characters.
+ auto upconvertedCharacters = manifestAfterSignature.upconvertedCharacters();
+ const UChar* p = upconvertedCharacters;
+ const UChar* end = p + manifestAfterSignature.length();
if (p < end && *p != ' ' && *p != '\t' && *p != '\n' && *p != '\r')
return false;
@@ -99,28 +100,28 @@ bool parseManifest(const URL& manifestURL, const char* data, int length, Manifes
else if (mode == Unknown)
continue;
else if (mode == Explicit || mode == OnlineWhitelist) {
- const UChar* p = line.deprecatedCharacters();
+ auto upconvertedLineCharacters = StringView(line).upconvertedCharacters();
+ const UChar* p = upconvertedLineCharacters;
const UChar* lineEnd = p + line.length();
// Look for whitespace separating the URL from subsequent ignored tokens.
while (p < lineEnd && *p != '\t' && *p != ' ')
p++;
- if (mode == OnlineWhitelist && p - line.deprecatedCharacters() == 1 && *line.deprecatedCharacters() == '*') {
+ if (mode == OnlineWhitelist && p - upconvertedLineCharacters == 1 && line[0] == '*') {
// Wildcard was found.
manifest.allowAllNetworkRequests = true;
continue;
}
- URL url(manifestURL, String(line.deprecatedCharacters(), p - line.deprecatedCharacters()));
+ URL url(manifestURL, line.substring(0, p - upconvertedLineCharacters));
if (!url.isValid())
continue;
- if (url.hasFragmentIdentifier())
- url.removeFragmentIdentifier();
+ url.removeFragmentIdentifier();
- if (!equalIgnoringCase(url.protocol(), manifestURL.protocol()))
+ if (!equalIgnoringASCIICase(url.protocol(), manifestURL.protocol()))
continue;
if (mode == Explicit && manifestURL.protocolIs("https") && !protocolHostAndPortAreEqual(manifestURL, url))
@@ -132,7 +133,8 @@ bool parseManifest(const URL& manifestURL, const char* data, int length, Manifes
manifest.onlineWhitelistedURLs.append(url);
} else if (mode == Fallback) {
- const UChar* p = line.deprecatedCharacters();
+ auto upconvertedLineCharacters = StringView(line).upconvertedCharacters();
+ const UChar* p = upconvertedLineCharacters;
const UChar* lineEnd = p + line.length();
// Look for whitespace separating the two URLs
@@ -144,11 +146,10 @@ bool parseManifest(const URL& manifestURL, const char* data, int length, Manifes
continue;
}
- URL namespaceURL(manifestURL, String(line.deprecatedCharacters(), p - line.deprecatedCharacters()));
+ URL namespaceURL(manifestURL, line.substring(0, p - upconvertedLineCharacters));
if (!namespaceURL.isValid())
continue;
- if (namespaceURL.hasFragmentIdentifier())
- namespaceURL.removeFragmentIdentifier();
+ namespaceURL.removeFragmentIdentifier();
if (!protocolHostAndPortAreEqual(manifestURL, namespaceURL))
continue;
@@ -165,8 +166,7 @@ bool parseManifest(const URL& manifestURL, const char* data, int length, Manifes
URL fallbackURL(manifestURL, String(fallbackStart, p - fallbackStart));
if (!fallbackURL.isValid())
continue;
- if (fallbackURL.hasFragmentIdentifier())
- fallbackURL.removeFragmentIdentifier();
+ fallbackURL.removeFragmentIdentifier();
if (!protocolHostAndPortAreEqual(manifestURL, fallbackURL))
continue;