fix: Unescape html character in eh metadata on server side

This commit is contained in:
2025-01-01 15:37:45 +08:00
parent 2339c5a113
commit 39b974876e
3 changed files with 10 additions and 2 deletions

6
db.ts
View File

@@ -351,7 +351,7 @@ export class EhDb {
#base_path: string;
#db_path: string;
#use_ffi = false;
readonly version = parse_ver("1.0.0-14");
readonly version = parse_ver("1.0.0-15");
constructor(base_path: string) {
this.#base_path = base_path;
this.#db_path = join(base_path, "data.db");
@@ -509,6 +509,10 @@ export class EhDb {
if (compare_ver(v, parse_ver("1.0.0-14")) === -1) {
this.db.execute(PMETA_INDEX);
}
if (compare_ver(v, parse_ver("1.0.0-15")) === -1) {
this.db.execute("DELETE FROM ehmeta;");
need_optimize = true;
}
this.#write_version();
if (need_optimize) this.optimize();
}

View File

@@ -12,7 +12,7 @@ export type GalleryMetadataTorrentInfo = {
export type GalleryMetadataSingle = {
gid: number;
token: string;
archiver_key: string;
archiver_key?: string;
/// HTML escaped
title: string;
/// HTML escaped

View File

@@ -11,6 +11,7 @@ import {
return_error,
} from "../../../server/utils.ts";
import { base_logger } from "../../../utils/logger.ts";
import { unescape } from "@std/html";
const logger = base_logger.get_logger("api-eh-metadata");
@@ -73,6 +74,9 @@ export const handler: Handlers = {
if (typeof v === "string") {
data[k.toString()] = gen_error(2, v);
} else {
v.title = unescape(v.title);
v.title_jpn = unescape(v.title_jpn);
v.uploader = unescape(v.uploader);
data[k.toString()] = gen_data(v);
m.db.add_ehmeta(v);
}