mirror of
https://github.com/directus/directus.git
synced 2026-02-18 01:11:26 -05:00
App: encode primary key (#5143)
* app: encode primary key Since primary keys could be manually entered strings, we should encode those in order to prevent accessing inexistent routes. E.g. Document with primary key: 'clients/John Doe' * fixup! app: encode primary key Since primary keys could be manually entered strings, we should encode those in order to prevent accessing inexistent routes. E.g. Document with primary key: 'clients/John Doe' Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
This commit is contained in:
@@ -87,7 +87,7 @@ export default defineComponent({
|
||||
const openItemLink = computed(() => {
|
||||
if (!item || !item.value) return;
|
||||
|
||||
return `/collections/${item.value.collection}/${item.value.item}`;
|
||||
return `/collections/${item.value.collection}/${encodeURIComponent(item.value.item)}`;
|
||||
});
|
||||
|
||||
watch(() => props.primaryKey, loadActivity, { immediate: true });
|
||||
|
||||
@@ -435,7 +435,7 @@ export default defineComponent({
|
||||
if (props.primaryKey === '+') {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const newPrimaryKey = savedItem[primaryKeyField.value!.field];
|
||||
router.replace(`/collections/${props.collection}/${newPrimaryKey}`);
|
||||
router.replace(`/collections/${props.collection}/${encodeURIComponent(newPrimaryKey)}`);
|
||||
}
|
||||
} catch {
|
||||
// Save shows unexpected error dialog
|
||||
@@ -461,7 +461,7 @@ export default defineComponent({
|
||||
async function saveAsCopyAndNavigate() {
|
||||
try {
|
||||
const newPrimaryKey = await saveAsCopy();
|
||||
if (newPrimaryKey) router.push(`/collections/${props.collection}/${newPrimaryKey}`);
|
||||
if (newPrimaryKey) router.push(`/collections/${props.collection}/${encodeURIComponent(newPrimaryKey)}`);
|
||||
} catch {
|
||||
// Save shows unexpected error dialog
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user