diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b7d5486d1..99e84c21d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,11 @@ should change the heading of the (upcoming) version to include a major version b # 5.19.4 +## @rjsf/core + +- Fix XSS when rendering schema validation errors [#4254](https://github.com/rjsf-team/react-jsonschema-form/issues/2718) + - NOTE: This will have potential consequences if you are using the [translateString](https://rjsf-team.github.io/react-jsonschema-form/docs/api-reference/form-props/#translatestring) feature and are trying to render HTML. Switching to [Markdown](https://www.markdownguide.org/) will solve your problems. + ## @rjsf/utils - Updated the `ValidatorType` interface to add an optional `reset?: () => void` prop that can be implemented to reset a validator back to initial constructed state diff --git a/packages/core/src/components/fields/ObjectField.tsx b/packages/core/src/components/fields/ObjectField.tsx index eb4e1d4d99..8399429da5 100644 --- a/packages/core/src/components/fields/ObjectField.tsx +++ b/packages/core/src/components/fields/ObjectField.tsx @@ -263,7 +263,7 @@ class ObjectField

- + {translateString(TranslatableString.InvalidObjectField, [name || 'root', (err as Error).message])}

diff --git a/packages/core/src/components/fields/SchemaField.tsx b/packages/core/src/components/fields/SchemaField.tsx index 5ac131609a..ee7bd23ca5 100644 --- a/packages/core/src/components/fields/SchemaField.tsx +++ b/packages/core/src/components/fields/SchemaField.tsx @@ -201,8 +201,11 @@ function SchemaFieldRender{description} : description; - + const richDescription = uiOptions.enableMarkdownInDescription ? ( + {description} + ) : ( + description + ); const help = uiOptions.help; const hidden = uiOptions.widget === 'hidden'; diff --git a/packages/core/src/components/templates/UnsupportedField.tsx b/packages/core/src/components/templates/UnsupportedField.tsx index f89d445f8e..bbce8c8f9f 100644 --- a/packages/core/src/components/templates/UnsupportedField.tsx +++ b/packages/core/src/components/templates/UnsupportedField.tsx @@ -27,7 +27,7 @@ function UnsupportedField

- {translateString(translateEnum, translateParams)} + {translateString(translateEnum, translateParams)}

{schema &&
{JSON.stringify(schema, null, 2)}
}