mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 12:54:38 +03:00
Fix invalid scene queue generated link (#1425)
* Escape quotes in criterion label JSON encoding and slicing off the encompassing JSON-string quotes seems like a safer option * Wrap criterion parse in try/catch to prevent the page from crashing
This commit is contained in:
@@ -425,13 +425,18 @@ export class ListFilterModel {
|
||||
}
|
||||
|
||||
jsonParameters.forEach((jsonString) => {
|
||||
const encodedCriterion = JSON.parse(jsonString);
|
||||
const criterion = makeCriteria(encodedCriterion.type);
|
||||
// it's possible that we have unsupported criteria. Just skip if so.
|
||||
if (criterion) {
|
||||
criterion.value = encodedCriterion.value;
|
||||
criterion.modifier = encodedCriterion.modifier;
|
||||
this.criteria.push(criterion);
|
||||
try {
|
||||
const encodedCriterion = JSON.parse(jsonString);
|
||||
const criterion = makeCriteria(encodedCriterion.type);
|
||||
// it's possible that we have unsupported criteria. Just skip if so.
|
||||
if (criterion) {
|
||||
criterion.value = encodedCriterion.value;
|
||||
criterion.modifier = encodedCriterion.modifier;
|
||||
this.criteria.push(criterion);
|
||||
}
|
||||
} catch (err) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error("Failed to parse encoded criterion:", err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ export interface ILabeledValue {
|
||||
}
|
||||
|
||||
export function encodeILabeledId(o: ILabeledId) {
|
||||
// escape \ to \\ so that it encodes to JSON correctly
|
||||
const adjustedLabel = o.label.replaceAll("\\", "\\\\");
|
||||
// escape " and \ and by encoding to JSON so that it encodes to JSON correctly down the line
|
||||
const adjustedLabel = JSON.stringify(o.label).slice(1, -1);
|
||||
return { ...o, label: encodeURIComponent(adjustedLabel) };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user