@buerokratt-ria/common-gui-components 0.0.35 → 0.0.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,14 @@ All changes to this project will be documented in this file.
4
4
 
5
5
  ## Template [MajorVersion.MediterraneanVersion.MinorVersion] - DD-MM-YYYY
6
6
 
7
+ ## [0.0.37] - 19.01.2026
8
+
9
+ - Added Sanitization to Markdownify
10
+
11
+ ## [0.0.36] - 14.01.2026
12
+
13
+ - Hide $backoffice, $validate_ and $general_knowledge from end user
14
+
7
15
  ## [0.0.35] - 09.01.2026
8
16
 
9
17
  - Fixed Pagination on date change
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buerokratt-ria/common-gui-components",
3
- "version": "0.0.35",
3
+ "version": "0.0.37",
4
4
  "description": "Common GUI components and pre defined templates.",
5
5
  "main": "index.ts",
6
6
  "author": "ExiRai",
@@ -59,7 +59,9 @@
59
59
  "use-debounce": "^10.0.1",
60
60
  "usehooks-ts": "^2.9.1",
61
61
  "uuid": "^9.0.0",
62
- "zustand": "^4.4.4"
62
+ "zustand": "^4.4.4",
63
+ "sanitize-html": "^2.17.0",
64
+ "@types/sanitize-html": "^2.16.0"
63
65
  },
64
66
  "devDependencies": {
65
67
  "@buerokratt-ria/header": "^0.1.20",
@@ -118,6 +120,8 @@
118
120
  "@types/react": "^18.0.26",
119
121
  "@types/react-cookies": "^0.1.3",
120
122
  "@types/react-dom": "^18.0.9",
121
- "typescript": "^5.7.3"
123
+ "typescript": "^5.7.3",
124
+ "sanitize-html": "^2.17.0",
125
+ "@types/sanitize-html": "^2.16.0"
122
126
  }
123
127
  }
@@ -1,6 +1,6 @@
1
1
  import React, { useState } from "react";
2
2
  import Markdown from "markdown-to-jsx";
3
- import "./Chat.scss";
3
+ import sanitizeHtml from "sanitize-html";
4
4
 
5
5
  interface MarkdownifyProps {
6
6
  message: string | undefined;
@@ -44,12 +44,19 @@ const LinkPreview: React.FC<{
44
44
  const hasSpecialFormat = (m: string) => m.includes("\n\n") && m.indexOf(".") > 0 && m.indexOf(":") > m.indexOf(".");
45
45
 
46
46
  function formatMessage(message?: string): string {
47
- if (!message) return "";
47
+ const sanitizedMessage = sanitizeHtml(message ?? "");
48
48
 
49
- return message
50
- .replace(/&#x([0-9A-Fa-f]+);/g, (_, hex) => String.fromCharCode(parseInt(hex, 16)))
51
- .replace(/(^|\n)(\d{4})\.\s/g, (match, prefix, year) => {
52
- const remainingText = message.substring(message.indexOf(match) + match.length);
49
+ if (!sanitizedMessage) return "";
50
+
51
+ const filteredMessage = sanitizedMessage
52
+ .replaceAll(/\\?\$b\w*/g, "")
53
+ .replaceAll(/\\?\$v\w*/g, "")
54
+ .replaceAll(/\\?\$g\w*/g, "");
55
+
56
+ return filteredMessage
57
+ .replaceAll(/&#x([0-9A-Fa-f]+);/g, (_, hex: string) => String.fromCharCode(parseInt(hex, 16)))
58
+ .replaceAll(/(^|\n)(\d{4})\.\s/g, (match, prefix, year) => {
59
+ const remainingText = filteredMessage.substring(filteredMessage.indexOf(match) + match.length);
53
60
  const sentenceEnd = remainingText.indexOf("\n\n");
54
61
  if (sentenceEnd !== -1) {
55
62
  const currentSentence = remainingText.substring(0, sentenceEnd);
@@ -59,7 +66,7 @@ function formatMessage(message?: string): string {
59
66
  }
60
67
  return `${prefix}${year}\\. `;
61
68
  })
62
- .replace(/(?<=\n)\d+\.\s/g, hasSpecialFormat(message) ? "\n\n$&" : "$&");
69
+ .replace(/(?<=\n)\d+\.\s/g, hasSpecialFormat(filteredMessage) ? "\n\n$&" : "$&");
63
70
  }
64
71
 
65
72
  const Markdownify: React.FC<MarkdownifyProps> = ({ message, sanitizeLinks = false }) => (