das-developers / das2java

The original das2 library. Provides interactive publication-ready 2-D plotting
https://das2.org
GNU Lesser General Public License v3.0
4 stars 0 forks source link

strange run batch bug where 2000 triggers time #109

Closed jbfaden closed 3 months ago

jbfaden commented 3 months ago

I ran across a strange bug where a string is interpreted as a time. In Autoplot:

  1. run batch https://github.com/autoplot/dev/blob/master/demos/2024/20240802/demoBugRunBatch.jy with a=[2,3,4] and c;d=[200;2000,200;3000,...] (generate parameters)
  2. write to png /tmp/ap/%6s%s%s.png
  3. some files will have the string as expected, like the second (...4000.png) attached image
  4. some pngs will have a date like the second (...2000.png).

I followed this back to where this results in a time: dataset('2 20 300 2000'). Further, the string could be interpreted as "2:20 on day 300 of year 2000", but it's a much more obscure time. Clearly the logic for discovering times needs to be less permissive.

jbfaden commented 3 months ago

What's going on is the routine which figures out the time was allowing 300 to be interpreted as a two-digit year. I've put in a check on the max of a two-digit year, to make sure it really is two digits.

However I can still get it to parse things which should not be parsed: dataset('2 20 2000 300'), and here there's a quick check to see if something is either European dates or American dates with a regex find. The find allows the USA date (M D Y) to be found, ignoring the trailing 300.

I've put in a check that no number can follow the USA or European date.

jbfaden commented 3 months ago

Codes which use the magnitude of numbers to guess their meaning should always be supervised by a human. So, it is fine to use these codes when interpreting the text entered in a GUI, but never in batch processing. Look out for use of dataset(string) when string is not carefully controlled.

jbfaden commented 3 months ago

See also https://sourceforge.net/p/autoplot/bugs/2607/