Fix NPEs in Liquid renderer

This commit is contained in:
Grahame Grieve 2024-05-21 16:55:17 -05:00
parent fae2d1336c
commit d9c1c74924
3 changed files with 14 additions and 6 deletions

View File

@ -285,7 +285,8 @@ public class LanguageUtils {
if (element.isPrimitive() && isTranslatable(element)) {
String base = element.primitiveValue();
if (base != null) {
Set<TranslationUnit> tlist = findTranslations(pathForElement(element), base, translations);
String path = pathForElement(element);
Set<TranslationUnit> tlist = findTranslations(path, base, translations);
for (TranslationUnit translation : tlist) {
t++;
if (!handleAsSpecial(parent, element, translation)) {

View File

@ -144,8 +144,13 @@ public class LiquidRenderer extends ResourceRenderer implements ILiquidRendering
} else {
x.tx(base.toString());
}
String res = new XhtmlComposer(true).compose(x).substring(5);
String res = new XhtmlComposer(true).compose(x);
res = res.substring(5);
if (res.length() < 6) {
return "";
} else {
return res.substring(0, res.length()-6);
}
} catch (FHIRFormatError e) {
throw new FHIRException(e);
} catch (IOException e) {

View File

@ -231,10 +231,12 @@ public class LiquidEngine implements IEvaluationContext {
StringBuilder b = new StringBuilder();
boolean first = true;
for (Base i : items) {
if (i != null) {
if (first) first = false; else b.append(", ");
String s = renderingSupport != null ? renderingSupport.renderForLiquid(ctxt.externalContext, i) : null;
b.append(s != null ? s : engine.convertToString(i));
}
}
return b.toString();
}
}