summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/NEWS.md2
-rw-r--r--src/item.cc2
-rw-r--r--test/regress/1702.test17
3 files changed, 20 insertions, 1 deletions
diff --git a/doc/NEWS.md b/doc/NEWS.md
index ce468b7f..f8196a20 100644
--- a/doc/NEWS.md
+++ b/doc/NEWS.md
@@ -6,6 +6,8 @@
- Make sorting order of lot information deterministic (bug #1747)
+- Fix bug in tag value parsing (bug #1702)
+
- Remove the `org` command, which was always a hack to begin with (bug #1706)
- Provide Docker information in README
diff --git a/src/item.cc b/src/item.cc
index 7132103e..d46fba8b 100644
--- a/src/item.cc
+++ b/src/item.cc
@@ -198,7 +198,7 @@ void item_t::parse_tags(const char * p,
tag = string(q, len - index);
string_map::iterator i;
- string field(p + len + index);
+ string field(p + (q - buf.get()) + len);
trim(field);
if (by_value) {
bind_scope_t bound_scope(scope, *this);
diff --git a/test/regress/1702.test b/test/regress/1702.test
new file mode 100644
index 00000000..813cf37b
--- /dev/null
+++ b/test/regress/1702.test
@@ -0,0 +1,17 @@
+tag Foo
+ assert value =~ /^Bar$/
+
+2019/01/01 * Payee
+ ;; Foo: Bar
+ Income:Foo $-1
+ Assets:Cash $1
+2019/01/01 * Another Payee
+ Assets:Cash $-1
+ Expenses:Baz $1
+
+test bal
+ $1 Expenses:Baz
+ $-1 Income:Foo
+--------------------
+ 0
+end test