Allow empty string to be passed to formAction (#26379)

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 [2788d0d8dd](https://github.com/facebook/react/commit/2788d0d8dd95ed57e2dbb148853fe69010e992fe)
This commit is contained in:
sebmarkbage
2023-03-13 18:34:16 +00:00
parent 6b8da26cc0
commit 89944512a2
25 changed files with 232 additions and 52 deletions
+1 -1
View File
@@ -1 +1 @@
131768166b60b3bc271b54a3f93f011f310519de
2788d0d8dd95ed57e2dbb148853fe69010e992fe
+1 -1
View File
@@ -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,
@@ -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;
@@ -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 = {
@@ -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__;
+13 -2
View File
@@ -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,
@@ -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,
+13 -2
View File
@@ -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,
@@ -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,
+13 -4
View File
@@ -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,
@@ -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 = {
@@ -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__;
@@ -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";
+13 -4
View File
@@ -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,
@@ -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 = {
@@ -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__;
@@ -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";
@@ -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,
@@ -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) {
@@ -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: {
@@ -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 (
@@ -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,
@@ -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) {
@@ -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) {
@@ -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 (
@@ -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");
@@ -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,
@@ -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");
@@ -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,
@@ -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,
@@ -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";
@@ -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,
@@ -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";
@@ -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,
@@ -196,7 +196,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,
@@ -1854,7 +1854,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,
@@ -31647,7 +31658,7 @@ function createFiberRoot(
return root;
}
var ReactVersion = "18.3.0-www-classic-9a02c30a";
var ReactVersion = "18.3.0-www-classic-87f4bed4";
function createPortal$1(
children,
@@ -1268,7 +1268,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,
@@ -38221,7 +38232,7 @@ function createFiberRoot(
return root;
}
var ReactVersion = "18.3.0-www-modern-915078f5";
var ReactVersion = "18.3.0-www-modern-067984be";
function createPortal$1(
children,
@@ -638,7 +638,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,
@@ -11729,7 +11738,7 @@ Internals.Events = [
var devToolsConfig$jscomp$inline_1552 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "18.3.0-www-classic-e28878a7",
version: "18.3.0-www-classic-dd1bbdc2",
rendererPackageName: "react-dom"
};
var internals$jscomp$inline_2106 = {
@@ -11759,7 +11768,7 @@ var internals$jscomp$inline_2106 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-www-classic-e28878a7"
reconcilerVersion: "18.3.0-www-classic-dd1bbdc2"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2107 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -15008,4 +15017,4 @@ exports.unstable_renderSubtreeIntoContainer = function (
);
};
exports.unstable_runWithPriority = runWithPriority;
exports.version = "18.3.0-www-classic-e28878a7";
exports.version = "18.3.0-www-classic-dd1bbdc2";
@@ -458,7 +458,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,
@@ -14105,7 +14114,7 @@ Internals.Events = [
var devToolsConfig$jscomp$inline_1672 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "18.3.0-www-modern-052eefbf",
version: "18.3.0-www-modern-f236d170",
rendererPackageName: "react-dom"
};
var internals$jscomp$inline_2080 = {
@@ -14136,7 +14145,7 @@ var internals$jscomp$inline_2080 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-www-modern-052eefbf"
reconcilerVersion: "18.3.0-www-modern-f236d170"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2081 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -14464,4 +14473,4 @@ exports.unstable_flushControlled = function (fn) {
}
};
exports.unstable_runWithPriority = runWithPriority;
exports.version = "18.3.0-www-modern-052eefbf";
exports.version = "18.3.0-www-modern-f236d170";
@@ -615,7 +615,17 @@ new PropertyInfoRecord(
true, // sanitizeURL
false
);
["src", "href", "action", "formAction"].forEach(function (attributeName) {
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
new PropertyInfoRecord(
attributeName,
@@ -615,7 +615,17 @@ new PropertyInfoRecord(
true, // sanitizeURL
false
);
["src", "href", "action", "formAction"].forEach(function (attributeName) {
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
new PropertyInfoRecord(
attributeName,
@@ -182,7 +182,8 @@ new PropertyInfoRecord(
!0,
!1
);
["src", "href", "action", "formAction"].forEach(function (attributeName) {
new PropertyInfoRecord("formAction", 1, !1, "formaction", null, !0, !1);
["src", "href", "action"].forEach(function (attributeName) {
new PropertyInfoRecord(
attributeName,
1,
@@ -182,7 +182,8 @@ new PropertyInfoRecord(
!0,
!1
);
["src", "href", "action", "formAction"].forEach(function (attributeName) {
new PropertyInfoRecord("formAction", 1, !1, "formaction", null, !0, !1);
["src", "href", "action"].forEach(function (attributeName) {
new PropertyInfoRecord(
attributeName,
1,
@@ -23954,7 +23954,7 @@ function createFiberRoot(
return root;
}
var ReactVersion = "18.3.0-www-modern-052eefbf";
var ReactVersion = "18.3.0-www-modern-f236d170";
// Might add PROFILE later.