Escape html special characters in properties.

This commit is contained in:
kovacsv 2022-05-29 11:26:58 +02:00
parent dc60397102
commit 6f54184dc6
3 changed files with 9 additions and 2 deletions

View File

@ -27,3 +27,8 @@ export function IsObjectEmpty (obj)
{
return Object.keys (obj).length === 0;
}
export function EscapeHtmlChars (str)
{
return str.replaceAll ('<', '&lt;').replaceAll ('>', '&gt;');
}

View File

@ -1,4 +1,4 @@
import { IsDefined, ValueOrDefault, CopyObjectAttributes, IsObjectEmpty } from './core/core.js';
import { IsDefined, ValueOrDefault, CopyObjectAttributes, IsObjectEmpty, EscapeHtmlChars } from './core/core.js';
import { TaskRunner, RunTaskAsync, RunTasks, RunTasksBatch, WaitWhile } from './core/taskrunner.js';
import { Exporter } from './export/exporter.js';
import { Exporter3dm } from './export/exporter3dm.js';
@ -75,6 +75,7 @@ export {
ValueOrDefault,
CopyObjectAttributes,
IsObjectEmpty,
EscapeHtmlChars,
TaskRunner,
RunTaskAsync,
RunTasks,

View File

@ -1,3 +1,4 @@
import { EscapeHtmlChars } from '../core/core.js';
import { ColorToHexString } from './color.js';
export const PropertyType =
@ -66,7 +67,7 @@ export class PropertyGroup
export function PropertyToString (property)
{
if (property.type === PropertyType.Text) {
return property.value;
return EscapeHtmlChars (property.value);
} else if (property.type === PropertyType.Integer) {
return property.value.toLocaleString ();
} else if (property.type === PropertyType.Number) {