Fixed issues with parsing METARS that could cause an ifinite loop crash and misinterpreted units#528
Merged
Merged
Conversation
apps4av
approved these changes
Apr 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, parseData() prevented parsing past the last token by not incrementing the index if it was already on the last token, which could lead to getting stuck in an infinite loop if the last token was a runway visual range group, a weather group, or a sky condition, eventually leading to a crash. This was fixed by unconditionally incrementing the index and then conditionally returning from the function if there were no more tokens to parse. This also fixed an oversight where the parser previously assumed non-empty METARS would have at least 3 tokens which could lead to indexing past the last token and causing an exception on missing/delayed METARS which may have their LocID or Time fields set to "NIL=" according to the GDL90 specification.
A sample of a problematic METAR that this fixes is as follows
METAR KMER 242355Z 35013KT 10SM CLR=
Additionally, the trailing '=' that may be included as an optional message delimiter would remain on the last token, which could cause unit detection using String.endsWith() to select the wrong units. This was fixed by removing the trailing '=' from the data string before parsing.