feat: encode publisher handle and template name in marketplace URLs for improved URL safety

This commit is contained in:
yessenia 2026-03-09 13:52:52 +08:00
parent 98449de4f6
commit 22d22f2b77
2 changed files with 6 additions and 3 deletions

View File

@ -43,9 +43,12 @@ const TemplateCardComponent = ({
templateId: id,
creationType: 'templates',
}
const encodedPublisherHandle = encodeURIComponent(publisher_handle)
const encodedTemplateName = encodeURIComponent(template_name)
return includeSource
? getMarketplaceUrl(`/template/${publisher_handle}/${template_name}`, queryParams)
: `${MARKETPLACE_URL_PREFIX}/template/${publisher_handle}/${template_name}?${buildSearchParamsString(queryParams)}`
? getMarketplaceUrl(`/template/${encodedPublisherHandle}/${encodedTemplateName}`, queryParams)
: `${MARKETPLACE_URL_PREFIX}/template/${encodedPublisherHandle}/${encodedTemplateName}?${buildSearchParamsString(queryParams)}`
}, [publisher_handle, template_name, theme, locale, id, includeSource])
const visibleDepsPlugins = deps_plugins?.slice(0, MAX_VISIBLE_DEPS_PLUGINS) || []

View File

@ -203,7 +203,7 @@ function TemplatesSection({ templates, includeSource, t }: {
<DropdownItem
key={template.id}
href={buildMarketplaceHref(
`/template/${template.publisher_handle}/${template.template_name}`,
`/template/${encodeURIComponent(template.publisher_handle)}/${encodeURIComponent(template.template_name)}`,
{ templateId: template.id },
includeSource,
)}