Skip to content

Commit 54e578b

Browse files
In token_from_request() make sure $_GET['token'] is a string (#35607)
* In token_from_request() make sure $_GET['token'] is a string Giving an array to preg_match() where it expects a string is a fatal error. Better to avoid that. * Update projects/plugins/jetpack/extensions/blocks/premium-content/_inc/subscription-service/class-abstract-token-subscription-service.php Fix typo Co-authored-by: Aaron Robertshaw <[email protected]> --------- Co-authored-by: Aaron Robertshaw <[email protected]>
1 parent 927a840 commit 54e578b

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Significance: patch
2+
Type: other
3+
Comment: In token_from_request() make sure $_GET['token'] is a string

projects/plugins/jetpack/extensions/blocks/premium-content/_inc/subscription-service/class-abstract-token-subscription-service.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ public static function clear_token_cookie() {
472472
private function token_from_request() {
473473
$token = null;
474474
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
475-
if ( isset( $_GET['token'] ) ) {
475+
if ( isset( $_GET['token'] ) && is_string( $_GET['token'] ) ) {
476476
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Recommended
477477
if ( preg_match( '/^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/', $_GET['token'], $matches ) ) {
478478
// token matches a valid JWT token pattern.

0 commit comments

Comments
 (0)