New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 801555 link

Starred by 2 users

Issue metadata

Status: Started
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

PushSubscription.toJSON encodes base64 values with padding

Reported by alexen...@gmail.com, Jan 12 2018

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.85 Safari/537.36

Steps to reproduce the problem:
1. Create a PushSubscription
2. call .toJSON or JSON.stringify

What is the expected behavior?
The values in keys should be encoded using URL safe base64 without padding

https://www.w3.org/TR/push-api/#dom-pushsubscription-tojson

What went wrong?
Instead the values are encoded with padding

Did this work before? N/A 

Does this work in other browsers? Yes

Chrome version: 64.0.3282.85  Channel: beta
OS Version: 10.0
Flash Version: Shockwave Flash 28.0 r0
 
Labels: Needs-Triage-M64
Cc: vamshi.k...@techmahindra.com
Labels: Triaged-ET Needs-Feedback
Thanks for filing the issue!

@Reporter: Could you please share a sample test file along with that it would be highly helpful if shared(if possible) a screenshot/screen cast which describes the issue. Any further inputs from your end helps us to triage the issue in a better way.

Comment 3 by alexen...@gmail.com, Jan 16 2018

Sure, where service-worker.js is a file that exists, the following shows the issue. The output is

{
	"endpoint": "https://fcm.googleapis.com/fcm/send/...",
	"expirationTime": null,
	"keys": {
		"p256dh": "BMwK00IJzqXYPCl7uZ7rDBR4GAahb9Z2JLMFEIJiHAlP_ree56DUV1-vTI1B2QC7gtILXm7ge-2EaThn702DGAc=",
		"auth": "G79lArMieJtphmTraMEcfA=="
	}
}

expected

{
	"endpoint": "https://fcm.googleapis.com/fcm/send/...",
	"expirationTime": null,
	"keys": {
		"p256dh": "BMwK00IJzqXYPCl7uZ7rDBR4GAahb9Z2JLMFEIJiHAlP_ree56DUV1-vTI1B2QC7gtILXm7ge-2EaThn702DGAc",
		"auth": "G79lArMieJtphmTraMEcfA"
	}
}
push-bug.js
631 bytes View Download
Project Member

Comment 4 by sheriffbot@chromium.org, Jan 16 2018

Labels: -Needs-Feedback
Thank you for providing more feedback. Adding requester "vamshi.kommuri@techmahindra.com" to the cc list and removing "Needs-Feedback" label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Comment 5 by peter@chromium.org, Jan 16 2018

Owner: peter@chromium.org
Status: Started (was: Unconfirmed)
Thank you for the report, this is a bug indeed! I've uploaded a change for review that should be included with Chrome 65.

https://chromium-review.googlesource.com/c/chromium/src/+/868295

Project Member

Comment 6 by bugdroid1@chromium.org, Jan 29 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/1be5b5e3d1866879e4d49e2ab34d4a89e3e2657a

commit 1be5b5e3d1866879e4d49e2ab34d4a89e3e2657a
Author: Peter Beverloo <peter@chromium.org>
Date: Mon Jan 29 17:36:17 2018

Strip padding from the JSON encoded PushSubscription data

The serialization contains the p256dh and auth values of the push
subscription encoded per base64url. Normally it's valid to keep the
trailing equal-sign padding, but the Push API specifically forbids this.

Bug: 801555
Change-Id: I370f01b6aa398ccd407502c967391ea573352381
Reviewed-on: https://chromium-review.googlesource.com/868295
Commit-Queue: Peter Beverloo <peter@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532474}
[modify] https://crrev.com/1be5b5e3d1866879e4d49e2ab34d4a89e3e2657a/third_party/WebKit/LayoutTests/http/tests/push_messaging/push-subscription-stringification.html
[modify] https://crrev.com/1be5b5e3d1866879e4d49e2ab34d4a89e3e2657a/third_party/WebKit/Source/modules/BUILD.gn
[modify] https://crrev.com/1be5b5e3d1866879e4d49e2ab34d4a89e3e2657a/third_party/WebKit/Source/modules/push_messaging/PushSubscription.cpp
[modify] https://crrev.com/1be5b5e3d1866879e4d49e2ab34d4a89e3e2657a/third_party/WebKit/Source/modules/push_messaging/PushSubscription.h
[add] https://crrev.com/1be5b5e3d1866879e4d49e2ab34d4a89e3e2657a/third_party/WebKit/Source/modules/push_messaging/PushSubscriptionTest.cpp

Sign in to add a comment