Skip to content

Commit

Permalink
fix NPE in validator around Extension context
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamegrieve committed Nov 25, 2024
1 parent aea8621 commit 9835bea
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Validator Changes

* no changes
* fix NPE in validator around Extension context

## Other code changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2479,22 +2479,26 @@ private boolean checkExtensionContext(Object appContext, List<ValidationMessage>
}
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) {
Expand Down

0 comments on commit 9835bea

Please sign in to comment.