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:
peolic
2021-05-25 04:18:09 +03:00
committed by GitHub
parent 5c4351f338
commit 3d93f7f0fe
3 changed files with 16 additions and 10 deletions

View File

@@ -5,11 +5,12 @@
* Added [DLNA server](/settings?tab=dlna). ([#1364](https://github.com/stashapp/stash/pull/1364))
### 🎨 Improvements
* Add `CreatedAt` and `UpdatedAt` (and `FileModTime` where applicable) to API objects.
* Add `CreatedAt` and `UpdatedAt` (and `FileModTime` where applicable) to API objects. ([#1421](https://github.com/stashapp/stash/pull/1421))
* Add Studios Performer filter criterion. ([#1405](https://github.com/stashapp/stash/pull/1405))
* Add `subtractDays` post-process scraper action. ([#1399](https://github.com/stashapp/stash/pull/1399))
* Skip scanning directories if path matches image and video exclude patterns. ([#1382](https://github.com/stashapp/stash/pull/1382))
* Add button to remove studio stash ID. ([#1378](https://github.com/stashapp/stash/pull/1378))
### 🐛 Bug fixes
* Fix quotes in filter labels causing UI errors. ([#1425](https://github.com/stashapp/stash/pull/1425))
* Fix post-processing not running when scraping by performer fragment. ([#1387](https://github.com/stashapp/stash/pull/1387))

View File

@@ -425,6 +425,7 @@ export class ListFilterModel {
}
jsonParameters.forEach((jsonString) => {
try {
const encodedCriterion = JSON.parse(jsonString);
const criterion = makeCriteria(encodedCriterion.type);
// it's possible that we have unsupported criteria. Just skip if so.
@@ -433,6 +434,10 @@ export class ListFilterModel {
criterion.modifier = encodedCriterion.modifier;
this.criteria.push(criterion);
}
} catch (err) {
// eslint-disable-next-line no-console
console.error("Failed to parse encoded criterion:", err);
}
});
}
}

View File

@@ -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) };
}