Skip to content

Commit

Permalink
refactor: reserve formatting separator char
Browse files Browse the repository at this point in the history
Signed-off-by: Gabor Boros <gabor.brs@gmail.com>
  • Loading branch information
gabor-boros committed Jun 9, 2022
1 parent 732d2cc commit 8e79795
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/rdb_protocol/terms/string.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ class format_term_t : public op_term_t {
base_exc_t::LOGIC,
"Nested template parameters are not allowed");

// Reserve "," for later use to implement formatting
rcheck(next_char != ':' || next_char != '\\',
base_exc_t::LOGIC,
printf("Formatting separator \"%c\" is not allowed in parameter name", next_char));

param_name.push_back(next_char);
++param_end_pos;
}
Expand Down
7 changes: 7 additions & 0 deletions test/rql_test/src/format.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,10 @@ tests:
ot: err('ReqlQueryLogicError', 'Expected type OBJECT but found STRING.')
- cd: r.format("{foo} bar baz", 1)
ot: err('ReqlQueryLogicError', 'Expected type OBJECT but found NUMBER.')
# Reserved formatting characters not allowed
- cd: r.format("foo {bar,} baz", {"bar,": "bar"})
rb: r.format("foo {bar:} baz", {"bar:" => "bar"})
ot: err('ReqlQueryLogicError', 'Formatting separator ":" is not allowed in parameter name')
- cd: r.format("foo {bar\} baz", {"bar\": "bar" })
rb: r.format("foo {bar:} baz", {"bar:" => "bar"})
ot: err('ReqlQueryLogicError', 'Formatting separator "\" is not allowed in parameter name')

0 comments on commit 8e79795

Please sign in to comment.