NOAA-MDL / GIFTs

Generate IWXXM From TAC software
Other
11 stars 2 forks source link

Some regular expressions should not be greedy #44

Closed mgoberfield closed 1 week ago

mgoberfield commented 6 months ago

Washington VAAC has provided a test case:

 FVXX27 KNES 191645
 VA ADVISORY
 DTG: 20240319/1645Z

 VAAC: WASHINGTON

 VOLCANO: TEST 999999
 PSN: N3700 W07700

 AREA: US

 SUMMIT ELEV: 32805 FT (9999 M)

 ADVISORY NR: 2024/001

 INFO SOURCE: TEST

 ERUPTION DETAILS: TEST AT 19/1700Z

 OBS VA DTG: 19/1645Z

 OBS VA CLD: VA NOT IDENTIFIABLE FROM SATELLITE
 DATA.

 FCST VA CLD +6HR: 19/2300Z NO VA EXP

 FCST VA CLD +12HR: 20/0500Z NO VA EXP

 FCST VA CLD +18HR: 20/1100Z NO VA EXP

 RMK: THIS IS A VA ADVISORY TEST MSG. MWO TAHITI
 SHOULD NOW ISSUE A SIGMET TEST MSG FOR VA
 ADVISORY IF RECEIVED. ...KIBLER

 NXT ADVISORY:  NO FURTHER ADVISORIES

The VAA TAC decoder halts with a message

2024-03-20 21:52:07,819 - tac_to_xml.vaa.vaaDecoder - INFO -
 VA ADVISORY TEST MSG. MWO TAHITI
            ^
 SHOULD NOW ISSUE A SIGMET TEST MSG FOR VA
 ADVISORY IF RECEIVED. ...KIBLER

 NXT ADVISORY:  NO FURTHER ADVISORIES

 Expecting test or exercise or Date/Time'

The regular expression did not stop at the first occurrence of 'VA ADVISORY' but instead halted at the last one, as indicated by the caret (^) position, that occurs in the remark section of the advisory. The decoder then attempted to process the text beginning at that point.

The regular expression in question needs to be not greedy and halt at the first occurrence instead which denotes the beginning of the message.