Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix form validation with js disabled #41947

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Forms: Fix 404 error when a user submits an invalid form with JavaScript disabled.
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public static function style_on() {
* @return string HTML for the concat form.
*/
public static function parse( $attributes, $content ) {
global $post, $page; // $page is used in the contact-form submission redirect
global $post, $page, $multipage; // $page is used in the contact-form submission redirect
if ( Settings::is_syncing() ) {
return '';
}
Expand Down Expand Up @@ -346,7 +346,7 @@ public static function parse( $attributes, $content ) {
} else {
// Submit form to the post permalink
$url = get_permalink();
if ( $page ) {
if ( $multipage && $page ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix is to only add the ?page query param to the form submission url if the post has more than one page. The $multipage global stores whether it's a multi page post with a value of 0 or 1 so we can use that to check.

Perhaps in classic themes it was possible for users to navigate to a URL like that and not end up on a 404 page, but it doesn't seem to be the case in block themes.

$url = add_query_arg( 'page', $page, $url );
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: bugfix

Forms: Fix 404 error when a user submits an invalid form with JavaScript disabled.
Loading