Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for unquoted config strings that start with number #893

Merged
merged 2 commits into from
Feb 6, 2019

Conversation

wallyqs
Copy link
Member

@wallyqs wallyqs commented Feb 1, 2019

Fixes parser to support string values that are not within quotes.

authorization {
  user = 3hello
  pass = 4world
}

Before it used to fail with an error as follows:

nats-server: Parse error on line 2: 'Expected a map value terminator "," or a map terminator "}", but got 'h' instead.'
  • Documentation added (if applicable)
  • Tests added
  • Branch rebased on top of current master (git pull --rebase origin master)
  • Changes squashed to a single commit (described here)
  • Build is green in Travis CI
  • You have certified that the contribution is your original work and that you license the work to the project under the Apache 2 license

Fixes #885

/cc @nats-io/core

@coveralls
Copy link

coveralls commented Feb 1, 2019

Coverage Status

Coverage remained the same at 91.668% when pulling 47055ed on wallyqs:config-string-num-val into 36b9026 on nats-io:master.

@derekcollison
Copy link
Member

My first question before even looking at code is what should this be? 12345678X. If numbers can only be all numbers I guess that is ok, but not sure how we handle that now.

@wallyqs
Copy link
Member Author

wallyqs commented Feb 1, 2019

Before this change, 123456789X would be undefined and cause a parsing error, for example:

log_file = 123456789X
// => nats-server: Parse error on line 8: 'Expected a top-level value to end with a new line, comment or EOF, but got 'X' instead.'

So the workaround is to put strings around log_file = "123456789X" which would work.

With the change in this branch now log_file = 123456789X without quotes is valid and treated as a string. There are some values that won't work as strings though, for example durations, which are given priority so that write_deadline = 5s even though it starts with a number it is still treated as a duration not as a string.

@derekcollison
Copy link
Member

ok LGTM! Thanks..

Signed-off-by: Waldemar Quevedo <wally@synadia.com>
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
@derekcollison
Copy link
Member

LGTM

@derekcollison derekcollison merged commit 5a79df1 into nats-io:master Feb 6, 2019
@wallyqs wallyqs deleted the config-string-num-val branch February 6, 2019 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants