Fix % character in tag name causing UI crash (#2757)

* Fix % character in tag name causing UI crash
This commit is contained in:
WithoutPants 2022-07-22 17:29:16 +10:00 committed by GitHub
parent db3138b33f
commit c21c334553
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 4 deletions

View file

@ -1,4 +1,5 @@
### 🐛 Bug fixes
* Fix UI crash when % character used in tag names. ([#2757](https://github.com/stashapp/stash/pull/2757))
* Fix keyboard shortcuts not working after selecting an object. ([#2750](https://github.com/stashapp/stash/pull/2750))
* Fix UI crash on session timeout. ([#2755](https://github.com/stashapp/stash/pull/2755))
* Fix incorrect scene metadata being set when video has cover art. ([#2752](https://github.com/stashapp/stash/pull/2752))

View file

@ -12,6 +12,7 @@ import DurationUtils from "src/utils/duration";
import {
CriterionType,
encodeILabeledId,
encodeLabel,
IHierarchicalLabelValue,
ILabeledId,
ILabeledValue,
@ -456,7 +457,7 @@ export class IHierarchicalLabeledIdCriterion extends Criterion<IHierarchicalLabe
public getLabelValue(): string {
const labels = decodeURI(
(this.value.items ?? []).map((v) => v.label).join(", ")
(this.value.items ?? []).map((v) => encodeLabel(v.label)).join(", ")
);
if (this.value.depth === 0) {

View file

@ -47,10 +47,14 @@ export function criterionIsNumberValue(
return typeof value === "object" && "value" in value && "value2" in value;
}
export function encodeILabeledId(o: ILabeledId) {
export function encodeLabel(v: string) {
// 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) };
const adjustedLabel = JSON.stringify(v).slice(1, -1);
return encodeURIComponent(adjustedLabel);
}
export function encodeILabeledId(o: ILabeledId) {
return { ...o, label: encodeLabel(o.label) };
}
export interface IOptionType {