Move slow GURL Java assert to faster c++ assert
Debatable whether this assert is necessary as I can't imagine GURL ever changing such that non-ASCII chars sneak into the output without breaking the world, but just in case... Bug: 1488235 Change-Id: Ic44208cc77d0caf10f0ef688195810031b1f8b77 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4904227 Commit-Queue: Michael Thiessen <mthiesse@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Cr-Commit-Position: refs/heads/main@{#1204735}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
479b71ab93
commit
dfcaecd980
url/android
@ -15,6 +15,7 @@
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/functional/callback.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "url/android/parsed_android.h"
|
||||
#include "url/third_party/mozilla/url_parse.h"
|
||||
#include "url/url_jni_headers/GURL_jni.h"
|
||||
@ -49,6 +50,10 @@ static std::unique_ptr<GURL> FromJavaGURL(JNIEnv* env,
|
||||
static void InitFromGURL(JNIEnv* env,
|
||||
const GURL& gurl,
|
||||
const JavaRef<jobject>& target) {
|
||||
// Ensure that the spec only contains US-ASCII (single-byte characters) or the
|
||||
// parsed indices will be wrong as the indices are in bytes while Java Strings
|
||||
// are always 16-bit.
|
||||
DCHECK(base::IsStringASCII(gurl.possibly_invalid_spec()));
|
||||
Java_GURL_init(
|
||||
env, target,
|
||||
base::android::ConvertUTF8ToJavaString(env, gurl.possibly_invalid_spec()),
|
||||
|
@ -135,8 +135,6 @@ public class GURL {
|
||||
@CalledByNative
|
||||
private void init(String spec, boolean isValid, Parsed parsed) {
|
||||
mSpec = spec;
|
||||
// Ensure that the spec only contains US-ASCII or the parsed indices will be wrong.
|
||||
assert mSpec.matches("\\A\\p{ASCII}*\\z");
|
||||
mIsValid = isValid;
|
||||
mParsed = parsed;
|
||||
}
|
||||
|
Reference in New Issue
Block a user