1
0
Fork 0

If loading plain text route, check for an XML header

Avoids errors when we try to parse an XML file as plain text.

Sentry-Id: FLIGHTGEAR-J6
This commit is contained in:
James Turner 2020-12-17 10:30:39 +00:00
parent d7155bde38
commit a092902483

View file

@ -1325,13 +1325,21 @@ bool FlightPlan::loadPlainTextFormat(const SGPath& path)
continue; // ignore empty/comment lines
}
// prevent Sentry error 'FLIGHTGEAR-J6', when we try loading XML
// data here
if (simgear::strutils::starts_with(line, "<?xml")) {
return false;
}
SGGeod vicinity;
if (!_legs.empty()) {
vicinity = _legs.back()->waypoint()->position();
}
WayptRef w = waypointFromString(line, vicinity);
if (!w) {
throw sg_io_exception("Failed to create waypoint from line '" + line + "'.");
SG_LOG(SG_NAVAID, SG_ALERT, "Failed to create waypoint from '" << line << "' in " << path);
_legs.clear();
return false;
}
_legs.push_back(LegRef{new Leg(this, w)});