Merge pull request #1829 from hapifhir/2024-11-gg-validator-npe

fix NPE in validator around Extension context
This commit is contained in:
Grahame Grieve 2024-11-25 15:00:20 +11:00 committed by GitHub
commit a5e0605a16
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 15 deletions

View File

@ -1,6 +1,6 @@
## Validator Changes
* no changes
* fix NPE in validator around Extension context
## Other code changes

View File

@ -2478,22 +2478,26 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
}
if (ctxt.getType() == ExtensionContextType.ELEMENT) {
String en = ctxt.getExpression();
contexts.append("e:" + en);
String pu = null;
if (en.contains("#")) {
pu = en.substring(0, en.indexOf("#"));
en = en.substring(en.indexOf("#")+1);
if (en == null) {
// nothing? It's an error in the extension definition, but that's properly reported elsewhere
} else {
//pu = en;
}
if (Utilities.existsInList(en, "Element", "Any")) {
ok = true;
} else if (en.equals("Resource") && container.isResource()) {
ok = true;
} else if (en.equals("CanonicalResource") && containsAny(VersionUtilities.getExtendedCanonicalResourceNames(context.getVersion()), plist)) {
ok = true;
} else if (hasElementName(plist, en) && pu == null) {
ok = true;
contexts.append("e:" + en);
if (en.contains("#")) {
pu = en.substring(0, en.indexOf("#"));
en = en.substring(en.indexOf("#")+1);
} else {
//pu = en;
}
if (Utilities.existsInList(en, "Element", "Any")) {
ok = true;
} else if (en.equals("Resource") && container.isResource()) {
ok = true;
} else if (en.equals("CanonicalResource") && containsAny(VersionUtilities.getExtendedCanonicalResourceNames(context.getVersion()), plist)) {
ok = true;
} else if (hasElementName(plist, en) && pu == null) {
ok = true;
}
}
if (!ok) {