Skip to content

Commit

Permalink
Allow empty string to be passed to formAction (#26379)
Browse files Browse the repository at this point in the history
We disallow empty strings for `href` and `src` since they're common
mistakes that end up loading the current page as a preload, image or
link. We also disallow it for `action`. You have to pass `null` which is
the same.

However, for `formAction` passing `null` is not the same as passing
empty string. Passing empty string overrides the form's action to be the
current page even if the form's action was set to something else.
There's no easy way to express the same thing `#` show up in the user
visible URLs and `?` clears the search params.

Since this is also not a common mistake, we can just allow this.

DiffTrain build for [2788d0d](2788d0d)
  • Loading branch information
sebmarkbage committed Mar 13, 2023
1 parent 6b8da26 commit 8994451
Show file tree
Hide file tree
Showing 25 changed files with 232 additions and 52 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
131768166b60b3bc271b54a3f93f011f310519de
2788d0d8dd95ed57e2dbb148853fe69010e992fe
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (
}
"use strict";

var ReactVersion = "18.3.0-www-modern-052eefbf";
var ReactVersion = "18.3.0-www-modern-f236d170";

// ATTENTION
// When adding new symbols to this file,
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/ReactART-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function _assertThisInitialized(self) {
return self;
}

var ReactVersion = "18.3.0-www-classic-e28878a7";
var ReactVersion = "18.3.0-www-classic-dd1bbdc2";

var LegacyRoot = 0;
var ConcurrentRoot = 1;
Expand Down
4 changes: 2 additions & 2 deletions compiled/facebook-www/ReactART-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -9555,7 +9555,7 @@ var slice = Array.prototype.slice,
return null;
},
bundleType: 0,
version: "18.3.0-www-modern-10cf7e02",
version: "18.3.0-www-modern-6722015e",
rendererPackageName: "react-art"
};
var internals$jscomp$inline_1283 = {
Expand Down Expand Up @@ -9586,7 +9586,7 @@ var internals$jscomp$inline_1283 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-www-modern-10cf7e02"
reconcilerVersion: "18.3.0-www-modern-6722015e"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1284 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
15 changes: 13 additions & 2 deletions compiled/facebook-www/ReactDOM-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -1811,7 +1811,18 @@ properties[xlinkHref] = new PropertyInfoRecord(
true, // sanitizeURL
false
);
["src", "href", "action", "formAction"].forEach(function (attributeName) {
var formAction = "formAction"; // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions

properties[formAction] = new PropertyInfoRecord(
"formAction",
STRING,
false, // mustUseProperty
"formaction", // attributeName
null, // attributeNamespace
true, // sanitizeURL
false
);
["src", "href", "action"].forEach(function (attributeName) {
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
properties[attributeName] = new PropertyInfoRecord(
attributeName,
Expand Down Expand Up @@ -42601,7 +42612,7 @@ function createFiberRoot(
return root;
}

var ReactVersion = "18.3.0-www-classic-bab45118";
var ReactVersion = "18.3.0-www-classic-e6bf1439";

function createPortal$1(
children,
Expand Down
15 changes: 13 additions & 2 deletions compiled/facebook-www/ReactDOM-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,18 @@ properties[xlinkHref] = new PropertyInfoRecord(
true, // sanitizeURL
false
);
["src", "href", "action", "formAction"].forEach(function (attributeName) {
var formAction = "formAction"; // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions

properties[formAction] = new PropertyInfoRecord(
"formAction",
STRING,
false, // mustUseProperty
"formaction", // attributeName
null, // attributeNamespace
true, // sanitizeURL
false
);
["src", "href", "action"].forEach(function (attributeName) {
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
properties[attributeName] = new PropertyInfoRecord(
attributeName,
Expand Down Expand Up @@ -42205,7 +42216,7 @@ function createFiberRoot(
return root;
}

var ReactVersion = "18.3.0-www-modern-10cf7e02";
var ReactVersion = "18.3.0-www-modern-6722015e";

function createPortal$1(
children,
Expand Down
17 changes: 13 additions & 4 deletions compiled/facebook-www/ReactDOM-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,16 @@ properties.xlinkHref = new PropertyInfoRecord(
!0,
!1
);
["src", "href", "action", "formAction"].forEach(function (attributeName) {
properties.formAction = new PropertyInfoRecord(
"formAction",
1,
!1,
"formaction",
null,
!0,
!1
);
["src", "href", "action"].forEach(function (attributeName) {
properties[attributeName] = new PropertyInfoRecord(
attributeName,
1,
Expand Down Expand Up @@ -15716,7 +15725,7 @@ Internals.Events = [
var devToolsConfig$jscomp$inline_1761 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "18.3.0-www-classic-a5e3f87b",
version: "18.3.0-www-classic-90a2338a",
rendererPackageName: "react-dom"
};
var internals$jscomp$inline_2156 = {
Expand Down Expand Up @@ -15746,7 +15755,7 @@ var internals$jscomp$inline_2156 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-www-classic-a5e3f87b"
reconcilerVersion: "18.3.0-www-classic-90a2338a"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2157 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down Expand Up @@ -16002,4 +16011,4 @@ exports.unstable_renderSubtreeIntoContainer = function (
);
};
exports.unstable_runWithPriority = runWithPriority;
exports.version = "18.3.0-www-classic-a5e3f87b";
exports.version = "18.3.0-www-classic-90a2338a";
17 changes: 13 additions & 4 deletions compiled/facebook-www/ReactDOM-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,16 @@ properties.xlinkHref = new PropertyInfoRecord(
!0,
!1
);
["src", "href", "action", "formAction"].forEach(function (attributeName) {
properties.formAction = new PropertyInfoRecord(
"formAction",
1,
!1,
"formaction",
null,
!0,
!1
);
["src", "href", "action"].forEach(function (attributeName) {
properties[attributeName] = new PropertyInfoRecord(
attributeName,
1,
Expand Down Expand Up @@ -15243,7 +15252,7 @@ Internals.Events = [
var devToolsConfig$jscomp$inline_1720 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "18.3.0-www-modern-46c135c4",
version: "18.3.0-www-modern-8420e676",
rendererPackageName: "react-dom"
};
var internals$jscomp$inline_2120 = {
Expand Down Expand Up @@ -15274,7 +15283,7 @@ var internals$jscomp$inline_2120 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-www-modern-46c135c4"
reconcilerVersion: "18.3.0-www-modern-8420e676"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2121 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down Expand Up @@ -15459,4 +15468,4 @@ exports.unstable_flushControlled = function (fn) {
}
};
exports.unstable_runWithPriority = runWithPriority;
exports.version = "18.3.0-www-modern-46c135c4";
exports.version = "18.3.0-www-modern-8420e676";
17 changes: 13 additions & 4 deletions compiled/facebook-www/ReactDOM-profiling.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,16 @@ properties.xlinkHref = new PropertyInfoRecord(
!0,
!1
);
["src", "href", "action", "formAction"].forEach(function (attributeName) {
properties.formAction = new PropertyInfoRecord(
"formAction",
1,
!1,
"formaction",
null,
!0,
!1
);
["src", "href", "action"].forEach(function (attributeName) {
properties[attributeName] = new PropertyInfoRecord(
attributeName,
1,
Expand Down Expand Up @@ -16493,7 +16502,7 @@ Internals.Events = [
var devToolsConfig$jscomp$inline_1841 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "18.3.0-www-classic-471dc273",
version: "18.3.0-www-classic-ac5c9cb7",
rendererPackageName: "react-dom"
};
(function (internals) {
Expand Down Expand Up @@ -16537,7 +16546,7 @@ var devToolsConfig$jscomp$inline_1841 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-www-classic-471dc273"
reconcilerVersion: "18.3.0-www-classic-ac5c9cb7"
});
assign(Internals, {
ReactBrowserEventEmitter: {
Expand Down Expand Up @@ -16780,7 +16789,7 @@ exports.unstable_renderSubtreeIntoContainer = function (
);
};
exports.unstable_runWithPriority = runWithPriority;
exports.version = "18.3.0-www-classic-471dc273";
exports.version = "18.3.0-www-classic-ac5c9cb7";

/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
Expand Down
17 changes: 13 additions & 4 deletions compiled/facebook-www/ReactDOM-profiling.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,16 @@ properties.xlinkHref = new PropertyInfoRecord(
!0,
!1
);
["src", "href", "action", "formAction"].forEach(function (attributeName) {
properties.formAction = new PropertyInfoRecord(
"formAction",
1,
!1,
"formaction",
null,
!0,
!1
);
["src", "href", "action"].forEach(function (attributeName) {
properties[attributeName] = new PropertyInfoRecord(
attributeName,
1,
Expand Down Expand Up @@ -16010,7 +16019,7 @@ Internals.Events = [
var devToolsConfig$jscomp$inline_1800 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "18.3.0-www-modern-2d8a876e",
version: "18.3.0-www-modern-0b070620",
rendererPackageName: "react-dom"
};
(function (internals) {
Expand Down Expand Up @@ -16055,7 +16064,7 @@ var devToolsConfig$jscomp$inline_1800 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-www-modern-2d8a876e"
reconcilerVersion: "18.3.0-www-modern-0b070620"
});
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals;
exports.createPortal = function (children, container) {
Expand Down Expand Up @@ -16227,7 +16236,7 @@ exports.unstable_flushControlled = function (fn) {
}
};
exports.unstable_runWithPriority = runWithPriority;
exports.version = "18.3.0-www-modern-2d8a876e";
exports.version = "18.3.0-www-modern-0b070620";

/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
Expand Down
15 changes: 13 additions & 2 deletions compiled/facebook-www/ReactDOMServer-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (__DEV__) {
var React = require("react");
var ReactDOM = require("react-dom");

var ReactVersion = "18.3.0-www-classic-de517acf";
var ReactVersion = "18.3.0-www-classic-6c50c84e";

// This refers to a WWW module.
var warningWWW = require("warning");
Expand Down Expand Up @@ -739,7 +739,18 @@ properties[xlinkHref] = new PropertyInfoRecord(
true, // sanitizeURL
false
);
["src", "href", "action", "formAction"].forEach(function (attributeName) {
var formAction = "formAction"; // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions

properties[formAction] = new PropertyInfoRecord(
"formAction",
STRING,
false, // mustUseProperty
"formaction", // attributeName
null, // attributeNamespace
true, // sanitizeURL
false
);
["src", "href", "action"].forEach(function (attributeName) {
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
properties[attributeName] = new PropertyInfoRecord(
attributeName,
Expand Down
15 changes: 13 additions & 2 deletions compiled/facebook-www/ReactDOMServer-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (__DEV__) {
var React = require("react");
var ReactDOM = require("react-dom");

var ReactVersion = "18.3.0-www-modern-ef6ae966";
var ReactVersion = "18.3.0-www-modern-0898b5b3";

// This refers to a WWW module.
var warningWWW = require("warning");
Expand Down Expand Up @@ -739,7 +739,18 @@ properties[xlinkHref] = new PropertyInfoRecord(
true, // sanitizeURL
false
);
["src", "href", "action", "formAction"].forEach(function (attributeName) {
var formAction = "formAction"; // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions

properties[formAction] = new PropertyInfoRecord(
"formAction",
STRING,
false, // mustUseProperty
"formaction", // attributeName
null, // attributeNamespace
true, // sanitizeURL
false
);
["src", "href", "action"].forEach(function (attributeName) {
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
properties[attributeName] = new PropertyInfoRecord(
attributeName,
Expand Down
13 changes: 11 additions & 2 deletions compiled/facebook-www/ReactDOMServer-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,16 @@ properties.xlinkHref = new PropertyInfoRecord(
!0,
!1
);
["src", "href", "action", "formAction"].forEach(function (attributeName) {
properties.formAction = new PropertyInfoRecord(
"formAction",
1,
!1,
"formaction",
null,
!0,
!1
);
["src", "href", "action"].forEach(function (attributeName) {
properties[attributeName] = new PropertyInfoRecord(
attributeName,
1,
Expand Down Expand Up @@ -3797,4 +3806,4 @@ exports.renderToString = function (children, options) {
'The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server'
);
};
exports.version = "18.3.0-www-classic-0c26a784";
exports.version = "18.3.0-www-classic-c710ea2f";
13 changes: 11 additions & 2 deletions compiled/facebook-www/ReactDOMServer-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,16 @@ properties.xlinkHref = new PropertyInfoRecord(
!0,
!1
);
["src", "href", "action", "formAction"].forEach(function (attributeName) {
properties.formAction = new PropertyInfoRecord(
"formAction",
1,
!1,
"formaction",
null,
!0,
!1
);
["src", "href", "action"].forEach(function (attributeName) {
properties[attributeName] = new PropertyInfoRecord(
attributeName,
1,
Expand Down Expand Up @@ -3695,4 +3704,4 @@ exports.renderToString = function (children, options) {
'The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server'
);
};
exports.version = "18.3.0-www-modern-b92877ae";
exports.version = "18.3.0-www-modern-3593be7c";
13 changes: 12 additions & 1 deletion compiled/facebook-www/ReactDOMServerStreaming-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,18 @@ properties[xlinkHref] = new PropertyInfoRecord(
true, // sanitizeURL
false
);
["src", "href", "action", "formAction"].forEach(function (attributeName) {
var formAction = "formAction"; // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions

properties[formAction] = new PropertyInfoRecord(
"formAction",
STRING,
false, // mustUseProperty
"formaction", // attributeName
null, // attributeNamespace
true, // sanitizeURL
false
);
["src", "href", "action"].forEach(function (attributeName) {
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
properties[attributeName] = new PropertyInfoRecord(
attributeName,
Expand Down
Loading

0 comments on commit 8994451

Please sign in to comment.