From 634f4cd76939c325a46ddfd3dab8c23472558649 Mon Sep 17 00:00:00 2001 From: zinigor Date: Mon, 9 Dec 2024 16:10:36 +0000 Subject: [PATCH] Merge remote-tracking branch 'origin/trunk' into prerelease Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/12239457541 Upstream-Ref: Automattic/jetpack@ee4f963ccf15f522b92e410414e1a768f12380a3 --- CHANGELOG.md | 8 ++++++++ package.json | 2 +- src/class-jetpack-forms.php | 2 +- src/contact-form/class-contact-form-field.php | 4 +++- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d64f43f..1aa8838 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.34.4-alpha] - unreleased + +This is an alpha version! The changes listed here are not final. + +### Fixed +- Form Block: fixed validation of URL input types to allow query strings. + ## [0.34.3] - 2024-12-09 ### Changed - Updated package dependencies. [#40363] @@ -733,6 +740,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added a new jetpack/forms package [#28409] - Added a public load_contact_form method for initializing the contact form module. [#28416] +[0.34.4-alpha]: https://github.com/automattic/jetpack-forms/compare/v0.34.3...v0.34.4-alpha [0.34.3]: https://github.com/automattic/jetpack-forms/compare/v0.34.2...v0.34.3 [0.34.2]: https://github.com/automattic/jetpack-forms/compare/v0.34.1...v0.34.2 [0.34.1]: https://github.com/automattic/jetpack-forms/compare/v0.34.0...v0.34.1 diff --git a/package.json b/package.json index 8931de7..781d198 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@automattic/jetpack-forms", - "version": "0.34.3", + "version": "0.34.4-alpha", "description": "Jetpack Forms", "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/forms/#readme", "bugs": { diff --git a/src/class-jetpack-forms.php b/src/class-jetpack-forms.php index 4b4b4ab..401817a 100644 --- a/src/class-jetpack-forms.php +++ b/src/class-jetpack-forms.php @@ -15,7 +15,7 @@ */ class Jetpack_Forms { - const PACKAGE_VERSION = '0.34.3'; + const PACKAGE_VERSION = '0.34.4-alpha'; /** * Load the contact form module. diff --git a/src/contact-form/class-contact-form-field.php b/src/contact-form/class-contact-form-field.php index 7182e25..332bcc0 100644 --- a/src/contact-form/class-contact-form-field.php +++ b/src/contact-form/class-contact-form-field.php @@ -227,6 +227,7 @@ public function validate() { switch ( $field_type ) { case 'url': if ( ! is_string( $field_value ) || empty( $field_value ) || ! preg_match( + // Changes to this regex should be synced with the regex in the render_url_field method of this class as both validate the same input. Note that this regex is in PCRE format. '%^(?:(?:https?|ftp)://)?(?:\S+(?::\S*)?@|\d{1,3}(?:\.\d{1,3}){3}|(?:(?:[a-z\d\x{00a1}-\x{ffff}]+-?)*[a-z\d\x{00a1}-\x{ffff}]+)(?:\.(?:[a-z\d\x{00a1}-\x{ffff}]+-?)*[a-z\d\x{00a1}-\x{ffff}]+)*(?:\.[a-z\x{00a1}-\x{ffff}]{2,6}))(?::\d+)?(?:[^\s]*)?$%iu', $field_value ) ) { @@ -590,7 +591,8 @@ public function render_url_field( $id, $label, $value, $class, $required, $requi 'title' => $custom_validation_message, 'oninvalid' => 'setCustomValidity("' . $custom_validation_message . '")', 'oninput' => 'setCustomValidity("")', - 'pattern' => '(([:\/a-zA-Z0-9_\-]+)?(\.[a-zA-Z0-9_\-\/]+)+)', + // Changes to this regex should be synced with the regex in the URL validation of the validate method of this class as both validate the same input. Note that this regex is in ECMAScript (JS) format. + 'pattern' => '(?:(?:[Hh][Tt][Tt][Pp][Ss]?|[Ff][Tt][Pp]):\/\/)?(?:\S+(?::\S*)?@|\d{1,3}(?:\.\d{1,3}){3}|(?:(?:[a-zA-Z\d\u00a1-\uffff]+-?)*[a-zA-Z\d\u00a1-\uffff]+)(?:\.(?:[a-zA-Z\d\u00a1-\uffff]+-?)*[a-zA-Z\d\u00a1-\uffff]+)*(?:\.[a-zA-Z\u00a1-\uffff]{2,6}))(?::\d+)?(?:[^\s]*)?', 'data-type-override' => 'url', );