Skip to content

Commit 1556f51

Browse files
authored
Revert href sanitization changes (#1015)
* Revert "Sanitize href props with xss vulnerability V2 (#1000)" This reverts commit 86a883b. * Update babel plugins * Revert tagname changes
1 parent 007b69b commit 1556f51

File tree

14 files changed

+59
-228
lines changed

14 files changed

+59
-228
lines changed

.babelrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"presets": ["@babel/preset-env", "@babel/preset-react"],
33
"plugins": [
4-
"@babel/plugin-proposal-object-rest-spread",
4+
"@babel/plugin-transform-object-rest-spread",
55
"@babel/plugin-transform-runtime"
66
],
77
"env": {
88
"test": {
9-
"plugins": ["@babel/plugin-proposal-class-properties"]
9+
"plugins": ["@babel/plugin-transform-class-properties"]
1010
}
1111
}
1212
}

package-lock.json

Lines changed: 28 additions & 56 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,11 @@
3434
"license": "Apache-2.0",
3535
"devDependencies": {
3636
"@babel/core": "^7.15.0",
37-
"@babel/plugin-proposal-class-properties": "^7.14.5",
38-
"@babel/plugin-proposal-object-rest-spread": "^7.14.7",
37+
"@babel/plugin-transform-class-properties": "^7.24.1",
38+
"@babel/plugin-transform-object-rest-spread": "^7.24.1",
3939
"@babel/plugin-transform-runtime": "^7.15.0",
4040
"@babel/preset-env": "^7.15.0",
4141
"@babel/preset-react": "^7.14.5",
42-
"@testing-library/dom": "^9.3.4",
4342
"@testing-library/jest-dom": "^5.14.1",
4443
"@testing-library/react": "^12.1.1",
4544
"@testing-library/user-event": "^13.2.1",
@@ -57,7 +56,6 @@
5756
"webpack-dev-server": "^4.7.4"
5857
},
5958
"dependencies": {
60-
"@braintree/sanitize-url": "^7.0.0",
6159
"@plotly/dash-component-plugins": "^1.2.0",
6260
"classnames": "^2.2.6",
6361
"fast-isnumeric": "^1.1.3",

src/components/badge/Badge.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {omit} from 'ramda';
44
import RBBadge from 'react-bootstrap/Badge';
55
import Link from '../../private/Link';
66
import {bootstrapColors} from '../../private/BootstrapColors';
7-
import {sanitizeAndCheckUrl} from '../../private/util';
87

98
/**
109
* Badges can be used to add counts or labels to other components.
@@ -23,8 +22,6 @@ const Badge = props => {
2322
...otherProps
2423
} = props;
2524

26-
const sanitizedUrl = sanitizeAndCheckUrl(href, setProps);
27-
2825
const incrementClicks = () => {
2926
if (setProps) {
3027
setProps({
@@ -39,8 +36,8 @@ const Badge = props => {
3936

4037
return (
4138
<RBBadge
42-
as={sanitizedUrl && Link}
43-
href={sanitizedUrl}
39+
as={href && Link}
40+
href={href}
4441
bg={isBootstrapColor ? color : null}
4542
text={text_color}
4643
className={class_name || className}

src/components/breadcrumb/Breadcrumb.js

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,10 @@ import PropTypes from 'prop-types';
33
import RBBreadcrumb from 'react-bootstrap/Breadcrumb';
44

55
import Link from '../../private/Link';
6-
import {sanitizeAndCheckUrl} from '../../private/util';
76

87
/**
98
* Use breadcrumbs to create a navigation breadcrumb in your app.
109
*/
11-
12-
const BreadcrumbItem = ({
13-
href,
14-
setProps,
15-
external_link,
16-
label,
17-
...otherProps
18-
}) => {
19-
const sanitizedUrl = sanitizeAndCheckUrl(href, setProps);
20-
21-
return (
22-
<RBBreadcrumb.Item
23-
linkAs={sanitizedUrl && Link}
24-
href={sanitizedUrl}
25-
linkProps={sanitizedUrl && {external_link}}
26-
{...otherProps}
27-
>
28-
{label}
29-
</RBBreadcrumb.Item>
30-
);
31-
};
32-
3310
const Breadcrumb = ({
3411
items,
3512
tag,
@@ -39,7 +16,6 @@ const Breadcrumb = ({
3916
item_class_name,
4017
itemClassName,
4118
item_style,
42-
setProps,
4319
...otherProps
4420
}) => (
4521
<RBBreadcrumb
@@ -51,12 +27,16 @@ const Breadcrumb = ({
5127
{...otherProps}
5228
>
5329
{(items || []).map((item, idx) => (
54-
<BreadcrumbItem
30+
<RBBreadcrumb.Item
5531
key={`${item.value}${idx}`}
32+
active={item.active}
33+
linkAs={item.href && Link}
5634
className={item_class_name || itemClassName}
57-
setProps={setProps}
58-
{...item}
59-
/>
35+
href={item.href}
36+
linkProps={item.href && {external_link: item.external_link}}
37+
>
38+
{item.label}
39+
</RBBreadcrumb.Item>
6040
))}
6141
</RBBreadcrumb>
6242
);

src/components/button/Button.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
33
import {omit} from 'ramda';
44
import RBButton from 'react-bootstrap/Button';
55
import Link from '../../private/Link';
6-
import {sanitizeAndCheckUrl} from '../../private/util';
76

87
/**
98
* A component for creating Bootstrap buttons with different style options. The
@@ -35,8 +34,6 @@ const Button = props => {
3534
...otherProps
3635
} = props;
3736

38-
const sanitizedUrl = sanitizeAndCheckUrl(href, setProps);
39-
4037
const incrementClicks = () => {
4138
if (!disabled && setProps) {
4239
setProps({
@@ -45,7 +42,7 @@ const Button = props => {
4542
});
4643
}
4744
};
48-
const useLink = sanitizedUrl && !disabled;
45+
const useLink = href && !disabled;
4946
otherProps[useLink ? 'preOnClick' : 'onClick'] = onClick || incrementClicks;
5047

5148
if (useLink) {
@@ -59,7 +56,7 @@ const Button = props => {
5956
as={useLink ? Link : 'button'}
6057
variant={outline ? `outline-${color}` : color}
6158
type={useLink ? undefined : type}
62-
href={disabled ? undefined : sanitizedUrl}
59+
href={disabled ? undefined : href}
6360
disabled={disabled}
6461
download={useLink ? download : undefined}
6562
name={useLink ? undefined : name}

src/components/card/CardLink.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
33
import {omit} from 'ramda';
44
import RBCard from 'react-bootstrap/Card';
55
import Link from '../../private/Link';
6-
import {sanitizeAndCheckUrl} from '../../private/util';
76

87
/**
98
* Use card link to add consistently styled links to your cards. Links can be
@@ -16,16 +15,12 @@ const CardLink = props => {
1615
disabled,
1716
className,
1817
class_name,
19-
href,
20-
setProps,
2118
...otherProps
2219
} = props;
2320

24-
const sanitizedUrl = sanitizeAndCheckUrl(href, setProps);
25-
2621
const incrementClicks = () => {
27-
if (!disabled && setProps) {
28-
setProps({
22+
if (!disabled && props.setProps) {
23+
props.setProps({
2924
n_clicks: props.n_clicks + 1,
3025
n_clicks_timestamp: Date.now()
3126
});
@@ -40,9 +35,8 @@ const CardLink = props => {
4035
as={Link}
4136
preOnClick={incrementClicks}
4237
disabled={disabled}
43-
href={sanitizedUrl}
4438
className={class_name || className}
45-
{...omit(['n_clicks', 'n_clicks_timestamp'], otherProps)}
39+
{...omit(['setProps', 'n_clicks', 'n_clicks_timestamp'], otherProps)}
4640
>
4741
{children}
4842
</RBCard.Link>

0 commit comments

Comments
 (0)