Skip to content

Commit

Permalink
fix: encode rison characters when searching (apache#16768)
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida committed Sep 22, 2021
1 parent 707936b commit 5bdf2a6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ flask==1.1.4
# flask-openid
# flask-sqlalchemy
# flask-wtf
flask-appbuilder==3.3.2
flask-appbuilder==3.3.3
# via apache-superset
flask-babel==1.0.0
# via flask-appbuilder
Expand Down Expand Up @@ -176,7 +176,7 @@ pgsanity==0.2.9
# via apache-superset
polyline==1.4.0
# via apache-superset
prison==0.1.3
prison==0.2.1
# via flask-appbuilder
pyarrow==4.0.1
# via apache-superset
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def get_git_sha() -> str:
"cryptography>=3.3.2",
"deprecation>=2.1.0, <2.2.0",
"flask>=1.1.0, <2.0.0",
"flask-appbuilder>=3.3.2, <4.0.0",
"flask-appbuilder>=3.3.3, <4.0.0",
"flask-caching>=1.10.0",
"flask-compress",
"flask-talisman",
Expand Down
3 changes: 2 additions & 1 deletion superset-frontend/src/components/ListView/Filters/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export default function SearchFilter({
const [value, setValue] = useState(initialValue || '');
const handleSubmit = () => {
if (value) {
onSubmit(value.trim());
// encode plus signs to prevent them from being converted into a space
onSubmit(value.trim().replace(/\+/g, '%2B'));
}
};
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
Expand Down
5 changes: 3 additions & 2 deletions superset-frontend/src/components/ListView/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ import {
ViewModeType,
} from './types';

// Define custom RisonParam for proper encoding/decoding
// Define custom RisonParam for proper encoding/decoding; note that
// plus symbols should be encoded to avoid being converted into a space
const RisonParam: QueryParamConfig<string, any> = {
encode: (data?: any | null) =>
data === undefined ? undefined : rison.encode(data),
data === undefined ? undefined : rison.encode(data).replace(/\+/g, '%2B'),
decode: (dataStr?: string | string[]) =>
dataStr === undefined || Array.isArray(dataStr)
? undefined
Expand Down

0 comments on commit 5bdf2a6

Please sign in to comment.