From 8bf37b5bdc351d674b4cc9f57426068b20a1ad71 Mon Sep 17 00:00:00 2001 From: thuster Date: Mon, 18 Mar 2024 12:50:43 +0100 Subject: [PATCH] [26241] add filterNonPrintable to setText of AbstractFindingModelAdapter --- .../findings/fhir/model/AbstractFindingModelAdapter.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bundles/ch.elexis.core.findings.fhir.model/src/ch/elexis/core/findings/fhir/model/AbstractFindingModelAdapter.java b/bundles/ch.elexis.core.findings.fhir.model/src/ch/elexis/core/findings/fhir/model/AbstractFindingModelAdapter.java index d080daa67d..cc0430dc8b 100644 --- a/bundles/ch.elexis.core.findings.fhir.model/src/ch/elexis/core/findings/fhir/model/AbstractFindingModelAdapter.java +++ b/bundles/ch.elexis.core.findings.fhir.model/src/ch/elexis/core/findings/fhir/model/AbstractFindingModelAdapter.java @@ -6,6 +6,7 @@ import java.util.Optional; import java.util.stream.Collectors; +import org.apache.commons.lang3.StringUtils; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.r4.model.DomainResource; import org.hl7.fhir.r4.model.Extension; @@ -46,6 +47,7 @@ public Optional getText() { @Override public void setText(String text) { + text = filterNonPrintable(text); Optional resource = loadResource(); if (resource.isPresent() && resource.get() instanceof DomainResource) { DomainResource domainResource = (DomainResource) resource.get(); @@ -82,4 +84,11 @@ public Map getStringExtensions() { } return Collections.emptyMap(); } + + private String filterNonPrintable(String input) { + if (StringUtils.isNotBlank(input)) { + return input.replaceAll("[\\p{Cntrl}&&[^\r\n\t]]", ""); //$NON-NLS-1$ //$NON-NLS-2$ + } + return input; + } }