Skip to content

Commit c4d7fa4

Browse files
author
taylor.smock
committed
Fix #22250: Abort on XML error elements
git-svn-id: https://josm.openstreetmap.de/svn/trunk@18541 0c6e7542-c601-0410-84e7-c038aed88b3b
1 parent c800314 commit c4d7fa4

File tree

2 files changed

+159
-114
lines changed

2 files changed

+159
-114
lines changed

src/org/openstreetmap/josm/io/OsmReader.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,17 @@ private void handleIllegalDataException(IllegalDataException e) throws XMLStream
201201
}
202202
}
203203

204+
private void parseError() throws XMLStreamException {
205+
while (parser.hasNext()) {
206+
int event = parser.next();
207+
if (event == XMLStreamConstants.CHARACTERS) {
208+
throwException(parser.getText());
209+
} else {
210+
throwException("Unknown error element type");
211+
}
212+
}
213+
}
214+
204215
private void parseRemark() throws XMLStreamException {
205216
while (parser.hasNext()) {
206217
int event = parser.next();
@@ -393,6 +404,8 @@ protected void parseUnknown(boolean printWarning) throws XMLStreamException {
393404
if (printWarning && ("note".equals(element) || "meta".equals(element))) {
394405
// we know that Overpass API returns those elements
395406
Logging.debug(tr("Undefined element ''{0}'' found in input stream. Skipping.", element));
407+
} else if ("error".equals(element)) {
408+
parseError();
396409
} else if (printWarning) {
397410
Logging.info(tr("Undefined element ''{0}'' found in input stream. Skipping.", element));
398411
}

0 commit comments

Comments
 (0)