Handle fields in yaml config files with "/" - fix for #3533

This commit is contained in:
Mike Primm 2021-12-05 20:32:22 -06:00
parent 2ef6bf35a5
commit a40830434d
3 changed files with 20 additions and 14 deletions

View File

@ -6,7 +6,7 @@ dependencies {
implementation 'org.eclipse.jetty:jetty-server:9.4.26.v20200117' implementation 'org.eclipse.jetty:jetty-server:9.4.26.v20200117'
implementation 'org.eclipse.jetty:jetty-servlet:9.4.26.v20200117' implementation 'org.eclipse.jetty:jetty-servlet:9.4.26.v20200117'
implementation 'com.googlecode.json-simple:json-simple:1.1.1' implementation 'com.googlecode.json-simple:json-simple:1.1.1'
implementation 'org.yaml:snakeyaml:1.23' implementation 'org.yaml:snakeyaml:1.29'
implementation 'com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:20180219.1' implementation 'com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:20180219.1'
implementation 'org.postgresql:postgresql:42.2.18' implementation 'org.postgresql:postgresql:42.2.18'
} }

View File

@ -138,9 +138,11 @@ public class ConfigurationNode implements Map<String, Object> {
public Object getObject(String path) { public Object getObject(String path) {
if (path.isEmpty()) if (path.isEmpty())
return entries; return entries;
// Try get first (in case '/' is legit part
Object v = get(path);
int separator = path.indexOf('/'); int separator = path.indexOf('/');
if (separator < 0) if ((v != null) || (separator < 0)) return v;
return get(path);
String localKey = path.substring(0, separator); String localKey = path.substring(0, separator);
Object subvalue = get(localKey); Object subvalue = get(localKey);
if (subvalue == null) if (subvalue == null)

View File

@ -452,10 +452,11 @@ class MarkerSetImpl implements MarkerSet {
boolean loadPersistentData(ConfigurationNode node) { boolean loadPersistentData(ConfigurationNode node) {
label = node.getString("label", setid); /* Get label */ label = node.getString("label", setid); /* Get label */
ConfigurationNode markernode = node.getNode("markers"); ConfigurationNode markernode = node.getNode("markers");
if(markernode != null) { if (markernode != null) {
for(String id : markernode.keySet()) { for(String id : markernode.keySet()) {
MarkerImpl marker = new MarkerImpl(id, this); /* Make and load marker */ MarkerImpl marker = new MarkerImpl(id, this); /* Make and load marker */
if(marker.loadPersistentData(markernode.getNode(id))) { ConfigurationNode cfg = markernode.getNode(id);
if ((cfg != null) && marker.loadPersistentData(cfg)) {
markers.put(id, marker); markers.put(id, marker);
} }
else { else {
@ -465,10 +466,11 @@ class MarkerSetImpl implements MarkerSet {
} }
} }
ConfigurationNode areamarkernode = node.getNode("areas"); ConfigurationNode areamarkernode = node.getNode("areas");
if(areamarkernode != null) { if (areamarkernode != null) {
for(String id : areamarkernode.keySet()) { for(String id : areamarkernode.keySet()) {
AreaMarkerImpl marker = new AreaMarkerImpl(id, this); /* Make and load marker */ AreaMarkerImpl marker = new AreaMarkerImpl(id, this); /* Make and load marker */
if(marker.loadPersistentData(areamarkernode.getNode(id))) { ConfigurationNode cfg = areamarkernode.getNode(id);
if ((cfg != null) && marker.loadPersistentData(cfg)) {
areamarkers.put(id, marker); areamarkers.put(id, marker);
if(marker.getBoostFlag()) { if(marker.getBoostFlag()) {
if(boostingareamarkers == null) { if(boostingareamarkers == null) {
@ -490,10 +492,11 @@ class MarkerSetImpl implements MarkerSet {
} }
} }
ConfigurationNode linemarkernode = node.getNode("lines"); ConfigurationNode linemarkernode = node.getNode("lines");
if(linemarkernode != null) { if (linemarkernode != null) {
for(String id : linemarkernode.keySet()) { for(String id : linemarkernode.keySet()) {
PolyLineMarkerImpl marker = new PolyLineMarkerImpl(id, this); /* Make and load marker */ PolyLineMarkerImpl marker = new PolyLineMarkerImpl(id, this); /* Make and load marker */
if(marker.loadPersistentData(linemarkernode.getNode(id))) { ConfigurationNode cfg = linemarkernode.getNode(id);
if ((cfg != null) && marker.loadPersistentData(cfg)) {
linemarkers.put(id, marker); linemarkers.put(id, marker);
} }
else { else {
@ -503,10 +506,11 @@ class MarkerSetImpl implements MarkerSet {
} }
} }
ConfigurationNode circlemarkernode = node.getNode("circles"); ConfigurationNode circlemarkernode = node.getNode("circles");
if(circlemarkernode != null) { if (circlemarkernode != null) {
for(String id : circlemarkernode.keySet()) { for(String id : circlemarkernode.keySet()) {
CircleMarkerImpl marker = new CircleMarkerImpl(id, this); /* Make and load marker */ CircleMarkerImpl marker = new CircleMarkerImpl(id, this); /* Make and load marker */
if(marker.loadPersistentData(circlemarkernode.getNode(id))) { ConfigurationNode cfg = circlemarkernode.getNode(id);
if ((cfg != null) && marker.loadPersistentData(cfg)) {
circlemarkers.put(id, marker); circlemarkers.put(id, marker);
if(marker.getBoostFlag()) { if(marker.getBoostFlag()) {
if(boostingcirclemarkers == null) { if(boostingcirclemarkers == null) {
@ -528,7 +532,7 @@ class MarkerSetImpl implements MarkerSet {
} }
} }
List<String> allowed = node.getList("allowedicons"); List<String> allowed = node.getList("allowedicons");
if(allowed != null) { if (allowed != null) {
for(String id : allowed) { for(String id : allowed) {
MarkerIconImpl icon = MarkerAPIImpl.getMarkerIconImpl(id); MarkerIconImpl icon = MarkerAPIImpl.getMarkerIconImpl(id);
if(icon != null) if(icon != null)
@ -542,12 +546,12 @@ class MarkerSetImpl implements MarkerSet {
minzoom = node.getInteger("minzoom", -1); minzoom = node.getInteger("minzoom", -1);
maxzoom = node.getInteger("maxzoom", -1); maxzoom = node.getInteger("maxzoom", -1);
if (minzoom == 0) minzoom = -1; if (minzoom == 0) minzoom = -1;
if(node.containsKey("showlabels")) if (node.containsKey("showlabels"))
showlabels = node.getBoolean("showlabels", false); showlabels = node.getBoolean("showlabels", false);
else else
showlabels = null; showlabels = null;
String defid = node.getString("deficon"); String defid = node.getString("deficon");
if((defid != null) && (MarkerAPIImpl.api != null)) { if ((defid != null) && (MarkerAPIImpl.api != null)) {
deficon = MarkerAPIImpl.getMarkerIconImpl(defid); deficon = MarkerAPIImpl.getMarkerIconImpl(defid);
} }
else { else {