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

Unified Diff: third_party/WebKit/Source/modules/push_messaging/PushManager.cpp

Issue 1816123002: Add testing for subscription from service workers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix asan errors Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/push_messaging/PushManager.cpp
diff --git a/third_party/WebKit/Source/modules/push_messaging/PushManager.cpp b/third_party/WebKit/Source/modules/push_messaging/PushManager.cpp
index c6fd24f3058c81833a64378776ae5abfa7f115f3..5f501e522bfde603e441d620536b8788f77faf21 100644
--- a/third_party/WebKit/Source/modules/push_messaging/PushManager.cpp
+++ b/third_party/WebKit/Source/modules/push_messaging/PushManager.cpp
@@ -38,14 +38,14 @@ String bufferSourceToString(const ArrayBufferOrArrayBufferView& applicationServe
{
// Check the validity of the sender info. It must be a 65 byte unencrypted key,
// which has the byte 0x04 as the first byte as a marker.
- char* input;
+ unsigned char* input;
int length;
if (applicationServerKey.isArrayBuffer()) {
- input = static_cast<char*>(
+ input = static_cast<unsigned char*>(
applicationServerKey.getAsArrayBuffer()->data());
length = applicationServerKey.getAsArrayBuffer()->byteLength();
} else if (applicationServerKey.isArrayBufferView()) {
- input = static_cast<char*>(
+ input = static_cast<unsigned char*>(
applicationServerKey.getAsArrayBufferView()->buffer()->data());
length = applicationServerKey.getAsArrayBufferView()->buffer()->byteLength();
} else {
@@ -53,8 +53,11 @@ String bufferSourceToString(const ArrayBufferOrArrayBufferView& applicationServe
return String();
}
+ // If the key is valid, just treat it as a string of bytes and pass it to
+ // the push service.
if (length == 65 && input[0] == 0x04)
- return WebString::fromUTF8(input, length);
+ return WebString::fromLatin1(input, length);
+
exceptionState.throwDOMException(InvalidAccessError, "The provided applicationServerKey is not valid.");
return String();
}

Powered by Google App Engine
This is Rietveld 408576698