From 50c829a5ccdfac52020f6ddd3e9eda7b87c11fd0 Mon Sep 17 00:00:00 2001 From: Steve Block Date: Mon, 12 Sep 2011 16:03:58 +0100 Subject: [PATCH] Fix handling of empty URLs when setting up the NoDomain error page Bug: 5293606 Change-Id: Iace4f8a56bc4d8b8cbd01fb369cecf22564b7c8c --- Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp b/Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp index 9de6c0915..31eed6224 100644 --- a/Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp +++ b/Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp @@ -373,10 +373,16 @@ void FrameLoaderClientAndroid::dispatchDidFailProvisionalLoad(const ResourceErro url.append(buf, res); } } + // Vector sets up its data buffer lazilly, so if failingUrl is the empty + // string, the data buffer will be null. This will result in sanitizedUrl + // being null, and the string substitution below will be a no-op. + // FIXME: Ideally we'd always have a non-empty URL, or at least improve the + // wording of the error page in this case. See http://b/5293782. + String sanitizedUrl = url.data() ? String(url.data(), url.size()) : ""; // Replace all occurances of %s with the failing url. String s = UTF8Encoding().decode((const char*)a->getBuffer(false), a->getLength()); - s = s.replace("%s", String(url.data(), url.size())); + s = s.replace("%s", sanitizedUrl); // Replace all occurances of %e with the error text s = s.replace("%e", error.localizedDescription()); -- 2.11.0