Skip to content

Commit 538b7fe

Browse files
authored
Merge pull request #9367 from GilbertCherrie/fix_searchbar_security_issue
Fix searchbar formtoken issue
2 parents 50967a1 + 9da63b8 commit 538b7fe

File tree

2 files changed

+1
-8
lines changed

2 files changed

+1
-8
lines changed

app/javascript/components/search-bar/index.jsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ import {
99
} from '@carbon/icons-react';
1010

1111
const SearchBar = ({ searchText, advancedSearch, action }) => {
12-
const formToken = () => {
13-
const csrfToken = document.querySelector('meta[name=csrf-token]');
14-
return csrfToken ? csrfToken.getAttribute('content') : '';
15-
};
1612
const [data, setData] = useState({
1713
formText: searchText || '',
1814
loading: false,
@@ -96,7 +92,7 @@ const SearchBar = ({ searchText, advancedSearch, action }) => {
9692
return (
9793
<div className="search_bar">
9894
<Form onSubmit={onSearch} method="post" id="search-bar-form">
99-
<input type="hidden" name="authenticity_token" value={formToken()} />
95+
<input type="hidden" name="authenticity_token" />
10096
<TextInput
10197
id="search_text"
10298
labelText={__('Search')}

app/javascript/spec/search-bar/__snapshots__/search-bar.spec.js.snap

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ exports[`Search Bar component should render the search bar component 1`] = `
1212
<input
1313
name="authenticity_token"
1414
type="hidden"
15-
value=""
1615
/>
1716
<TextInput
1817
hideLabel={true}
@@ -73,7 +72,6 @@ exports[`Search Bar component should render the search bar component with advanc
7372
<input
7473
name="authenticity_token"
7574
type="hidden"
76-
value=""
7775
/>
7876
<TextInput
7977
hideLabel={true}
@@ -134,7 +132,6 @@ exports[`Search Bar component should render the search bar component with search
134132
<input
135133
name="authenticity_token"
136134
type="hidden"
137-
value=""
138135
/>
139136
<TextInput
140137
hideLabel={true}

0 commit comments

Comments
 (0)