diff options
author | John Wiegley <johnw@newartisans.com> | 2009-11-15 05:17:05 -0500 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-11-15 05:49:52 -0500 |
commit | 38e165a99408b9020ff2ea6fea5449f7a7e58698 (patch) | |
tree | 2d12ac7bfc689a3445347de094236f5a0c43a1c0 /src/item.cc | |
parent | 41212cd4c1f570d199e564009798fd233c3f9be2 (diff) | |
download | fork-ledger-38e165a99408b9020ff2ea6fea5449f7a7e58698.tar.gz fork-ledger-38e165a99408b9020ff2ea6fea5449f7a7e58698.tar.bz2 fork-ledger-38e165a99408b9020ff2ea6fea5449f7a7e58698.zip |
Made the transaction date parser a bit more strict
Diffstat (limited to 'src/item.cc')
-rw-r--r-- | src/item.cc | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/item.cc b/src/item.cc index 43274cfd..da6429ed 100644 --- a/src/item.cc +++ b/src/item.cc @@ -118,17 +118,20 @@ void item_t::set_tag(const string& tag, void item_t::parse_tags(const char * p, optional<date_t::year_type> current_year) { if (const char * b = std::strchr(p, '[')) { - if (const char * e = std::strchr(p, ']')) { - char buf[256]; - std::strncpy(buf, b + 1, e - b - 1); - buf[e - b - 1] = '\0'; - - if (char * p = std::strchr(buf, '=')) { - *p++ = '\0'; - _date_eff = parse_date(p, current_year); + if (*(b + 1) != '\0' && + (std::isdigit(*(b + 1)) || *(b + 1) == '=')) { + if (const char * e = std::strchr(p, ']')) { + char buf[256]; + std::strncpy(buf, b + 1, e - b - 1); + buf[e - b - 1] = '\0'; + + if (char * p = std::strchr(buf, '=')) { + *p++ = '\0'; + _date_eff = parse_date(p, current_year); + } + if (buf[0]) + _date = parse_date(buf, current_year); } - if (buf[0]) - _date = parse_date(buf, current_year); } } |