Aegisub icon indicating copy to clipboard operation
Aegisub copied to clipboard

Fail to parse .ass file when some margin is not an integer

Open ALRBP opened this issue 4 months ago • 3 comments

If a margin value in a .ass file is not an integer, eg. it is empty (",,") or a float (",25.00,") the parser fails with a "bad lexical cast" error.

Please find attached a minimal file to reproduce (had to change the ext to ".txt" for GitHub to accept it).

minimal.txt

I already have a working fix. Pull request incoming.

ALRBP avatar Sep 28 '25 23:09 ALRBP

Ideally this should match the libass implementation, which also allows for leading space, as well as (somewhat bizarrely) hexadecimal; and returns 0 when it fails to parse an integer from the content

petzku avatar Sep 28 '25 23:09 petzku

Ideally this should match the libass implementation, which also allows for leading space, as well as (somewhat bizarrely) hexadecimal; and returns 0 when it fails to parse an integer from the content

Not the case in my PR. I can change it to match this behavior.

ALRBP avatar Sep 29 '25 00:09 ALRBP

PR updated

Should match the wanted behavior. Could have been much simple using std::stoi with base=0, but this would have lead to values with leading 0 be read as base 8, which is not wanted.

Updated test file

minimal+.txt

ALRBP avatar Sep 29 '25 01:09 ALRBP