Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add id escaping

dominik-zeglen265176683e32
diff --git a/saleor/static/dashboard-next/categories/index.tsx b/saleor/static/dashboard-next/categories/index.tsx
index 2e2155f776..2f756993f0 100644
--- a/saleor/static/dashboard-next/categories/index.tsx
+++ b/saleor/static/dashboard-next/categories/index.tsx
@@ -14,12 +14,17 @@ const CategoryDetails: React.StatelessComponent<RouteComponentProps<any>> = ({
after: qs.after,
before: qs.before
};
- return <CategoryDetailsView id={match.params.id} params={params} />;
+ return (
+ <CategoryDetailsView
+ id={decodeURIComponent(match.params.id)}
+ params={params}
+ />
+ );
};
const CategoryCreate: React.StatelessComponent<RouteComponentProps<any>> = ({
match
}) => {
- return <CategoryCreateView parentId={match.params.id} />;
+ return <CategoryCreateView parentId={decodeURIComponent(match.params.id)} />;
};
const Component = ({ match }) => (
diff --git a/saleor/static/dashboard-next/categories/views/CategoryCreate.tsx b/saleor/static/dashboard-next/categories/views/CategoryCreate.tsx
index af72fd30d2..5fb8e544df 100644
--- a/saleor/static/dashboard-next/categories/views/CategoryCreate.tsx
+++ b/saleor/static/dashboard-next/categories/views/CategoryCreate.tsx
@@ -23,7 +23,9 @@ export const CategoryCreateView: React.StatelessComponent<
const handleSuccess = (data: CategoryCreate) => {
if (data.categoryCreate.errors.length === 0) {
pushMessage({ text: i18n.t("Category created") });
- navigate(categoryUrl(data.categoryCreate.category.id));
+ navigate(
+ categoryUrl(encodeURIComponent(data.categoryCreate.category.id))
+ );
}
};
return (
@@ -32,7 +34,9 @@ export const CategoryCreateView: React.StatelessComponent<
<CategoryCreatePage
errors={maybe(() => data.categoryCreate.errors, [])}
disabled={loading}
- onBack={() => navigate(categoryUrl(parentId))}
+ onBack={() =>
+ navigate(categoryUrl(encodeURIComponent(parentId)))
+ }
onSubmit={formData =>
mutate({
variables: {
diff --git a/saleor/static/dashboard-next/categories/views/CategoryDetails/index.tsx b/saleor/static/dashboard-next/categories/views/CategoryDetails/index.tsx
index 65141fd1c6..0f7bc9bf07 100644
--- a/saleor/static/dashboard-next/categories/views/CategoryDetails/index.tsx
+++ b/saleor/static/dashboard-next/categories/views/CategoryDetails/index.tsx
@@ -98,26 +98,36 @@ export const CategoryDetails: React.StatelessComponent<
)}
placeholderImage={""}
onAddCategory={() =>
- navigate(categoryAddUrl(id))
+ navigate(
+ categoryAddUrl(encodeURIComponent(id))
+ )
}
onAddProduct={() => navigate(productAddUrl)}
onBack={() =>
navigate(
categoryUrl(
- maybe(() => data.category.parent.id)
+ maybe(() =>
+ encodeURIComponent(
+ data.category.parent.id
+ )
+ )
)
)
}
onCategoryClick={id => () =>
- navigate(categoryUrl(id))}
- onDelete={() => navigate(categoryDeleteUrl(id))}
+ navigate(categoryUrl(encodeURIComponent(id)))}
+ onDelete={() =>
+ navigate(
+ categoryDeleteUrl(encodeURIComponent(id))
+ )
+ }
onImageDelete={() => undefined}
onImageUpload={() => undefined}
onNextPage={paginationData.loadNextPage}
onPreviousPage={paginationData.loadPreviousPage}
pageInfo={paginationData.pageInfo}
onProductClick={id => () =>
- navigate(productUrl(id))}
+ navigate(productUrl(encodeURIComponent(id)))}
onSubmit={formData =>
updateCategory({
variables: {
@@ -152,7 +162,10 @@ export const CategoryDetails: React.StatelessComponent<
render={({ match }) => (
<ActionDialog
onClose={() =>
- navigate(categoryUrl(id), true)
+ navigate(
+ categoryUrl(encodeURIComponent(id)),
+ true
+ )
}
onConfirm={() =>
deleteCategory({ variables: { id } })
diff --git a/saleor/static/dashboard-next/categories/views/CategoryList.tsx b/saleor/static/dashboard-next/categories/views/CategoryList.tsx
index 4f22a6172f..b5680ca7d6 100644
--- a/saleor/static/dashboard-next/categories/views/CategoryList.tsx
+++ b/saleor/static/dashboard-next/categories/views/CategoryList.tsx
@@ -17,7 +17,8 @@ export const CategoryList: React.StatelessComponent = () => (
[]
)}
onAddCategory={() => navigate(categoryAddUrl())}
- onCategoryClick={id => () => navigate(categoryUrl(id))}
+ onCategoryClick={id => () =>
+ navigate(categoryUrl(encodeURIComponent(id)))}
/>
)}
</TypedRootCategoriesQuery>
diff --git a/saleor/static/dashboard-next/products/components/ProductUpdatePage/ProductUpdatePage.tsx b/saleor/static/dashboard-next/products/components/ProductUpdatePage/ProductUpdatePage.tsx
index e1ed51b2e2..b20b2e5e97 100644
--- a/saleor/static/dashboard-next/products/components/ProductUpdatePage/ProductUpdatePage.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductUpdatePage/ProductUpdatePage.tsx
@@ -14,6 +14,7 @@ import SaveButtonBar, {
import SeoForm from "../../../components/SeoForm";
import Toggle from "../../../components/Toggle";
import i18n from "../../../i18n";
+import { ProductDetails_product_images_edges_node } from "../../types/ProductDetails";
import ProductAvailabilityForm from "../ProductAvailabilityForm";
import ProductDetailsForm from "../ProductDetailsForm";
import ProductImages from "../ProductImages";
@@ -46,12 +47,7 @@ interface ProductUpdateProps {
stockQuantity: number;
margin: number;
}>;
- images?: Array<{
- id: string;
- alt?: string;
- sortOrder: number;
- url: string;
- }>;
+ images?: ProductDetails_product_images_edges_node[];
product?: {
id: string;
name: string;