fix: encode rison characters when searching (#16768)

This commit is contained in:
Beto Dealmeida 2021-09-22 10:06:24 -07:00 committed by GitHub
parent 5cb49d2de0
commit 4af5ae08f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 6 deletions

View File

@ -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
@ -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

View File

@ -75,7 +75,7 @@ setup(
"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",

View File

@ -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>) => {

View File

@ -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