Skip to content

Commit

Permalink
coverPhotoStyle need to be encoded
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyperghost committed Dec 6, 2024
1 parent dab00bf commit 663c9a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions ts/WoltLabSuite/Core/Component/User/CoverPhoto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import WoltlabCoreFile from "WoltLabSuite/Core/Component/File/woltlab-core-file"
import { fire as fireEvent } from "WoltLabSuite/Core/Event/Handler";
import { getPhrase } from "WoltLabSuite/Core/Language";
import DomUtil from "WoltLabSuite/Core/Dom/Util";
import { unescapeHTML } from "WoltLabSuite/Core/StringUtil";
import { escapeHTML } from "WoltLabSuite/Core/StringUtil";

type ResponseGetForm = {
dialog: string;
Expand All @@ -36,7 +36,7 @@ async function editCoverPhoto(button: HTMLElement): Promise<void> {

dialog.addEventListener("afterClose", () => {
const file = dialog.querySelector<WoltlabCoreFile>("woltlab-core-file");
const coverPhotoUrl = unescapeHTML(file?.link ?? defaultCoverPhoto ?? "");
const coverPhotoUrl = file?.link ?? defaultCoverPhoto ?? "";
const coverPhotoStyle = `url("${coverPhotoUrl}")`;

if (FormBuilderManager.hasForm(json.formId)) {
Expand All @@ -49,13 +49,13 @@ async function editCoverPhoto(button: HTMLElement): Promise<void> {
}

if (coverPhotoElement && coverPhotoUrl) {
coverPhotoElement.style.setProperty("background-image", coverPhotoStyle, "");
coverPhotoElement.style.backgroundImage = coverPhotoStyle;
} else {
// ACP cover photo management
if (!coverPhotoElement && coverPhotoUrl) {
coverPhotoNotice!.parentElement!.appendChild(
DomUtil.createFragmentFromHtml(
`<div id="coverPhotoPreview" style="background-image: ${coverPhotoStyle};"></div>`,
`<div id="coverPhotoPreview" style="background-image: ${escapeHTML(coverPhotoStyle)};"></div>`,
),
);
coverPhotoNotice!.remove();
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 663c9a6

Please sign in to comment.