diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java index 1e7bb2055..6813cfefe 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java @@ -335,6 +335,7 @@ public class ProfileUtilities extends TranslatingUtilities { private boolean autoFixSliceNames; private XVerExtensionManager xver; private boolean wantFixDifferentialFirstElementType; + private List masterSourceFileNames; public ProfileUtilities(IWorkerContext context, List messages, ProfileKnowledgeProvider pkp, FHIRPathEngine fpe) { super(); @@ -2452,19 +2453,19 @@ public class ProfileUtilities extends TranslatingUtilities { if (webUrl != null) { // also, must touch up the markdown if (element.hasDefinition()) - element.setDefinition(processRelativeUrls(element.getDefinition(), webUrl, baseSpecUrl(), context.getResourceNames())); + element.setDefinition(processRelativeUrls(element.getDefinition(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames)); if (element.hasComment()) - element.setComment(processRelativeUrls(element.getComment(), webUrl, baseSpecUrl(), context.getResourceNames())); + element.setComment(processRelativeUrls(element.getComment(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames)); if (element.hasRequirements()) - element.setRequirements(processRelativeUrls(element.getRequirements(), webUrl, baseSpecUrl(), context.getResourceNames())); + element.setRequirements(processRelativeUrls(element.getRequirements(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames)); if (element.hasMeaningWhenMissing()) - element.setMeaningWhenMissing(processRelativeUrls(element.getMeaningWhenMissing(), webUrl, baseSpecUrl(), context.getResourceNames())); + element.setMeaningWhenMissing(processRelativeUrls(element.getMeaningWhenMissing(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames)); } } return element; } - public static String processRelativeUrls(String markdown, String webUrl, String basePath, List resourceNames) { + public static String processRelativeUrls(String markdown, String webUrl, String basePath, List resourceNames, List filenames) { StringBuilder b = new StringBuilder(); int i = 0; while (i < markdown.length()) { @@ -2485,7 +2486,7 @@ public class ProfileUtilities extends TranslatingUtilities { // This code is trying to guess which relative references are actually to the // base specification. // - if (isLikelySourceURLReference(url, resourceNames)) { + if (isLikelySourceURLReference(url, resourceNames, filenames)) { b.append("]("); b.append(basePath); i = i + 1; @@ -2507,7 +2508,7 @@ public class ProfileUtilities extends TranslatingUtilities { } - public static boolean isLikelySourceURLReference(String url, List resourceNames) { + public static boolean isLikelySourceURLReference(String url, List resourceNames, List filenames) { if (resourceNames != null) { for (String n : resourceNames) { if (url.startsWith(n.toLowerCase()+".html")) { @@ -2518,6 +2519,13 @@ public class ProfileUtilities extends TranslatingUtilities { } } } + if (filenames != null) { + for (String n : filenames) { + if (url.startsWith(n.toLowerCase())) { + return true; + } + } + } return url.startsWith("extensibility.html") || url.startsWith("terminologies.html") || @@ -6660,5 +6668,14 @@ public class ProfileUtilities extends TranslatingUtilities { public ElementDefinitionResolution resolveContentRef(StructureDefinition structure, ElementDefinition element) { return getElementById(structure, structure.getSnapshot().getElement(), element.getContentReference()); } + + public List getMasterSourceFileNames() { + return masterSourceFileNames; + } + + public void setMasterSourceFileNames(List masterSourceFileNames) { + this.masterSourceFileNames = masterSourceFileNames; + } + } diff --git a/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/UnicodeUtilitiesTests.java b/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/UnicodeUtilitiesTests.java index a1fdadd7f..f4f214390 100644 --- a/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/UnicodeUtilitiesTests.java +++ b/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/UnicodeUtilitiesTests.java @@ -22,7 +22,7 @@ public class UnicodeUtilitiesTests { Assertions.assertNull(UnicodeUtilities.checkUnicodeWellFormed(UnicodeUtilities.RLI + " "+ UnicodeUtilities.LRI + "a b c "+ UnicodeUtilities.PDI+" "+UnicodeUtilities.LRI+" d e f "+UnicodeUtilities.PDI+" "+UnicodeUtilities.PDI)); Assertions.assertEquals(UnicodeUtilities.checkUnicodeWellFormed("'''subject funds from back account then "+UnicodeUtilities.RLI + "''' ;return"), - "Unicode has unterminated bi-di control characters (see CVE-2021-42574): Unicode Character RLI at index 40 has no terminating match"); + "Unicode Character RLI at index 40 has no terminating match"); } - + }