Skip to content

Commit

Permalink
[26241] add filterNonPrintable to setText of AbstractFindingModelAdapter
Browse files Browse the repository at this point in the history
  • Loading branch information
huthomas committed Mar 18, 2024
1 parent 7a432d1 commit 4565569
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -46,6 +47,7 @@ public Optional<String> getText() {

@Override
public void setText(String text) {
text = filterNonPrintable(text);
Optional<IBaseResource> resource = loadResource();
if (resource.isPresent() && resource.get() instanceof DomainResource) {
DomainResource domainResource = (DomainResource) resource.get();
Expand Down Expand Up @@ -82,4 +84,11 @@ public Map<String, String> 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;
}
}

0 comments on commit 4565569

Please sign in to comment.