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
3 changed files with 10 additions and 4 deletions

View File

@@ -1,4 +1,5 @@
### 🐛 Bug fixes ### 🐛 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 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 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)) * 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 { import {
CriterionType, CriterionType,
encodeILabeledId, encodeILabeledId,
encodeLabel,
IHierarchicalLabelValue, IHierarchicalLabelValue,
ILabeledId, ILabeledId,
ILabeledValue, ILabeledValue,
@@ -456,7 +457,7 @@ export class IHierarchicalLabeledIdCriterion extends Criterion<IHierarchicalLabe
public getLabelValue(): string { public getLabelValue(): string {
const labels = decodeURI( 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) { if (this.value.depth === 0) {

View File

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