Library: Explicitly escape "#" characters in path names #3695

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2023-09-19 23:55:56 +02:00
parent 43655ba591
commit b65362b35a
3 changed files with 15 additions and 5 deletions

View File

@@ -294,7 +294,10 @@ export default {
type: Object, type: Object,
default: () => {}, default: () => {},
}, },
uid: String, uid: {
type: String,
default: "",
},
}, },
data() { data() {
return { return {
@@ -365,8 +368,11 @@ export default {
} }
const name = m.Name; const name = m.Name;
const path = name.substring(0, name.lastIndexOf('/'));
// "#" chars in path names must be explicitly escaped,
// see https://github.com/photoprism/photoprism/issues/3695
const path = name.substring(0, name.lastIndexOf('/'))
.replaceAll(":", "%3A").replaceAll("#", "%23");
return this.$router.resolve({ path: '/index/files/' + path }).href; return this.$router.resolve({ path: '/index/files/' + path }).href;
}, },
downloadFile(file) { downloadFile(file) {

View File

@@ -145,8 +145,9 @@ export class Folder extends RestModel {
path = "/" + path; path = "/" + path;
} }
// Escape ":" in URL path. // "#" chars in path names must be explicitly escaped,
path = path.replaceAll(":", "%3A"); // see https://github.com/photoprism/photoprism/issues/3695
path = path.replaceAll(":", "%3A").replaceAll("#", "%23");
return Api.get(this.getCollectionResource() + path, options).then((response) => { return Api.get(this.getCollectionResource() + path, options).then((response) => {
let folders = response.data.folders ? response.data.folders : []; let folders = response.data.folders ? response.data.folders : [];

View File

@@ -217,7 +217,10 @@ export default {
// Open Edit Dialog // Open Edit Dialog
Event.publish("dialog.edit", {selection: [model.PhotoUID], album: null, index: 0}); Event.publish("dialog.edit", {selection: [model.PhotoUID], album: null, index: 0});
} else { } else {
this.$router.push({path: '/index/files/' + model.Path}); // "#" chars in path names must be explicitly escaped,
// see https://github.com/photoprism/photoprism/issues/3695
const path = model.Path.replaceAll(":", "%3A").replaceAll("#", "%23");
this.$router.push({path: '/index/files/' + path});
} }
}, },
downloadFile(index) { downloadFile(index) {