From 2b01a95681df361f6867899eb46cd9ae4f3008a2 Mon Sep 17 00:00:00 2001 From: Beto Dealmeida Date: Mon, 20 Sep 2021 16:32:52 -0700 Subject: [PATCH] fix: encode rison characters when searching --- requirements/base.txt | 4 ++-- setup.py | 2 +- superset-frontend/src/components/ListView/Filters/Search.tsx | 3 ++- superset-frontend/src/components/ListView/utils.ts | 5 +++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/requirements/base.txt b/requirements/base.txt index 6be64d1f79acb..cbbc55f7295e8 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -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 diff --git a/setup.py b/setup.py index 9ce697b4acd20..8f72eb7940638 100644 --- a/setup.py +++ b/setup.py @@ -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", diff --git a/superset-frontend/src/components/ListView/Filters/Search.tsx b/superset-frontend/src/components/ListView/Filters/Search.tsx index 23a8e6900a41f..2f54cf960af00 100644 --- a/superset-frontend/src/components/ListView/Filters/Search.tsx +++ b/superset-frontend/src/components/ListView/Filters/Search.tsx @@ -35,7 +35,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 onClear = () => { diff --git a/superset-frontend/src/components/ListView/utils.ts b/superset-frontend/src/components/ListView/utils.ts index 7f9166395b5fb..b0619603840c1 100644 --- a/superset-frontend/src/components/ListView/utils.ts +++ b/superset-frontend/src/components/ListView/utils.ts @@ -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 = { 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