Skip to content

Commit 41aee76

Browse files
committed
Fix sonar issues
1 parent d54200e commit 41aee76

2 files changed

Lines changed: 3 additions & 7 deletions

File tree

apps/web/src/HtmlUtils.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ Please see LICENSE files in the repository root for full details.
1111

1212
import React, { type JSX, type Key, type LegacyRef, type ReactNode } from "react";
1313
import {
14-
sanitizeHtmlText,
15-
isUrlPermitted,
1614
sanitizeHtml,
1715
type HtmlSanitizeOptions,
1816
} from "@element-hq/element-web-shared-utils";
@@ -30,6 +28,7 @@ import { sanitizeHtmlParams, transformTags, linkifyHtml } from "./Linkify";
3028
import { graphemeSegmenter } from "./utils/strings";
3129

3230
export { linkifyAndSanitizeHtml } from "./Linkify";
31+
export { isUrlPermitted, sanitizeHtmlText } from "@element-hq/element-web-shared-utils";
3332

3433
// Anything outside the basic multilingual plane will be a surrogate pair
3534
const SURROGATE_PAIR_PATTERN = /([\ud800-\udbff])([\udc00-\udfff])/;
@@ -108,9 +107,6 @@ export function sanitizedHtmlNode(
108107
return <div dangerouslySetInnerHTML={{ __html: saneHtml }} dir="auto" className={className} />;
109108
}
110109

111-
// Keep the app-facing export stable for settings and context-menu consumers.
112-
export { isUrlPermitted, sanitizeHtmlText };
113-
114110
// this is the same as the above except with less rewriting
115111
const composerSanitizeHtmlParams: HtmlSanitizeOptions = {
116112
...sanitizeHtmlParams,

packages/shared-utils/src/html/sanitizeHtmlParams.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ function isTransform(value: HtmlSanitizeTransform | undefined): value is HtmlSan
9494
*/
9595
function hasUnsafeControlCharacter(input: string): boolean {
9696
return [...input].some((character) => {
97-
const code = character.charCodeAt(0);
98-
return code <= 0x20 || (code >= 0x7f && code <= 0x9f);
97+
const code = character.codePointAt(0);
98+
return code !== undefined && (code <= 0x20 || (code >= 0x7f && code <= 0x9f));
9999
});
100100
}
101101

0 commit comments

Comments
 (0)