-
Notifications
You must be signed in to change notification settings - Fork 61
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
Allow spaces in configuration values #244
Labels
feature
New feature
Comments
fluca1978
added a commit
to fluca1978/pgagroal
that referenced
this issue
May 25, 2022
This commit refactors the `extract_key_value()` function to handle quoted strings as values. A quoted string must start with either '"' or '\''. Everything between the quotes is handled as a value. If quotes do not match (e.g., "foo') the value is not set, so the line is ignored at all. Quoted strings can contain also spaces and comment charaters. Therefore, the following is a good string: log_line_prefix = "PGAGROAL #%Y-%m-%d-%H:%M:%S" Also, quotes can be nested: log_line_prefix = "'PGAGROAL' #%Y-%m-%d-%H:%M:%S" Values that do not need a quoting (because of spaces or comment signs) can be quoted as well, and that will not affect the value parsing. The following two lines are the same: log_rotation_size = 1M log_rotation_size = "1M" The `extract_key_value()` function now returns also an integer to indicate if it has parsed the key and the value correctly. The return value is not used because there is already a check on the validity of both key and value in `pgagroal_read_configuration()`, but to be coherent the function returns a status. This commit also allows to use comment-only line that begin with spaces or tabs, therefore the following are all ignored lines. The `is_comment_line()` function has therefore been refactored so that the following is a valid snippet of configuration: ; comment ; comment <tab> ; comment Last, a comment can be placed on the right side of a configuration option, so log_line_prefix = "PGAGROAL #%Y-%m-%d-%H:%M:%S" # the prefix is a valid line. The trick here is that any space after the option makes the rest of the line ignored. But now, even without spaces the comment is ignored: log_type = create; overwrites the file Updated also the documentation to reflect the changes. Close agroal#244
fluca1978
added a commit
to fluca1978/pgagroal
that referenced
this issue
May 25, 2022
This commit refactors the `extract_key_value()` function to handle quoted strings as values. A quoted string must start with either '"' or '\''. Everything between the quotes is handled as a value. If quotes do not match (e.g., "foo') the value is not set, so the line is ignored at all. Quoted strings can contain also spaces and comment charaters. Therefore, the following is a good string: log_line_prefix = "PGAGROAL #%Y-%m-%d-%H:%M:%S" Also, quotes can be nested: log_line_prefix = "'PGAGROAL' #%Y-%m-%d-%H:%M:%S" Values that do not need a quoting (because of spaces or comment signs) can be quoted as well, and that will not affect the value parsing. The following two lines are the same: log_rotation_size = 1M log_rotation_size = "1M" The `extract_key_value()` function now returns also an integer to indicate if it has parsed the key and the value correctly. The return value is not used because there is already a check on the validity of both key and value in `pgagroal_read_configuration()`, but to be coherent the function returns a status. This commit also allows to use comment-only line that begin with spaces or tabs, therefore the following are all ignored lines. The `is_comment_line()` function has therefore been refactored so that the following is a valid snippet of configuration: ; comment ; comment <tab> ; comment Last, a comment can be placed on the right side of a configuration option, so log_line_prefix = "PGAGROAL #%Y-%m-%d-%H:%M:%S" # the prefix is a valid line. The trick here is that any space after the option makes the rest of the line ignored. But now, even without spaces the comment is ignored: log_type = create; overwrites the file Updated also the documentation to reflect the changes. Close agroal#244
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The main configuration file
pgagroal.conf
does not allow spaces within the value of a key.This means that, for instance, the following:
will result effectively as
and quoting is not supported, so the following:
will result effectively in
It should be possible to change the
extrac_key_and_value()
function to handle quoted strings and thus spaces in configuratin values.The text was updated successfully, but these errors were encountered: