From 152ad3bf3d938d54a1df79f75b5aa05ab5fbb27a Mon Sep 17 00:00:00 2001 From: Pratik Chanda Date: Sat, 25 Oct 2025 00:45:46 +0530 Subject: [PATCH] hash: Use encoding for slugs in dm narrow hashes. Slugs in dm urls aren't really passed through url decoding and shouldn't throw any error currently if hashReplacement aren't enforced. But we still encode them in this commit to make this consistent. --- web/src/people.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/src/people.ts b/web/src/people.ts index 9f7cf3d595..86fba6a91c 100644 --- a/web/src/people.ts +++ b/web/src/people.ts @@ -2,6 +2,7 @@ import md5 from "blueimp-md5"; import assert from "minimalistic-assert"; import * as z from "zod/mini"; +import * as internal_url from "../shared/src/internal_url.ts"; import * as typeahead from "../shared/src/typeahead.ts"; import * as blueslip from "./blueslip.ts"; @@ -650,7 +651,7 @@ export function pm_perma_link(message: Message): string | undefined { } export function get_slug_from_full_name(full_name: string): string { - return full_name.replaceAll(/[ "%/<>`\p{C}]+/gu, "-"); + return internal_url.encodeHashComponent(full_name.replaceAll(/[ "%/<>`\p{C}]+/gu, "-")); } export function pm_with_url(message: Message | MessageWithBooleans): string | undefined {