Increase maximum length for regex

Fixes bug #981
This commit is contained in:
Martin Michlmayr 2016-02-15 13:58:18 -08:00
parent 82ef9dc388
commit c5f68caa9e
3 changed files with 34 additions and 2 deletions

View file

@ -1,5 +1,9 @@
Ledger NEWS
* 3.1.2
- Increased maximum length for regex from 255 to 4095.
* 3.1.1
- Added a --no-revalued option

View file

@ -303,8 +303,8 @@ void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags)
kind = SLASH;
} else { // terminal context
// Read in the regexp
char buf[256];
READ_INTO_(in, buf, 255, c, length, c != '/');
char buf[4096];
READ_INTO_(in, buf, 4095, c, length, c != '/');
if (c != '/')
expected('/', c);
in.get(c);

28
test/regress/981.test Normal file
View file

@ -0,0 +1,28 @@
; Test a regex longer than 255 char
tag Project
check value =~ /^(0ad|ankur|aptosid|archlinux|chakra|debian|debconf14|debconf15|debconf16|drizzle|ffmpeg|ffmpeg|fluxbox|freedesktop|freedombox|gallery|texmacs|haskell|jenkins|libreoffice|madwifi|mingw|openvas|openwrt|openbioinformatics|openembedded|openvoting|osunix|path64|plan9|postgresql|privoxy|smc|helios|tidesdk|tux4kids|yafaray|spi)$/
2016-01-01 * Test - correct tag
Expenses:Hosting 20.00 USD
; Project: debian
Assets:Cash -20.00 USD
2016-02-01 * Test - wrong tag
Expenses:Hosting 20.00 USD
; Project: foo
Assets:Cash -20.00 USD
test bal
-40.00 USD Assets:Cash
40.00 USD Expenses:Hosting
--------------------
0
__ERROR__
Warning: "/home/tbm/tmp/src/ledger/test/regress/981.test", line 15: Metadata check failed for (Project: foo): (value =~ /^(0ad|ankur|aptosid|archlinux|chakra|debian|debconf14|debconf15|debconf16|drizzle|ffmpeg|ffmpeg|fluxbox|freedesktop|freedombox|gallery|texmacs|haskell|jenkins|libreoffice|madwifi|mingw|openvas|openwrt|openbioinformatics|openembedded|openvoting|osunix|path64|plan9|postgresql|privoxy|smc|helios|tidesdk|tux4kids|yafaray|spi)$/)
end test
test reg --limit 'payee =~ /XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/'
end test