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 'escaped values' #48

Merged
merged 1 commit into from
Aug 5, 2024
Merged

Support for 'escaped values' #48

merged 1 commit into from
Aug 5, 2024

Conversation

michaelklishin
Copy link
Collaborator

@michaelklishin michaelklishin commented Aug 3, 2024

Problem Definition

Currently Cuttlefish does not support string
values that include the # character.

This character is, however, used every so often
in generated passwords, identifiers, messaging protocol
(AMQP 0-9-1, MQTTv3.1, MQTTv5) routing patterns,
and other (often machine-produced) values.

The Proposed Solution

This PR introduces an alternative value
representation:

a.setting = 'sdkjf#hsdf$82836867#9237498'

which allows such values to be escaped using
single quotes.

Given the following schema file:

{mapping, "escaped.value", "escaped.value", [
  {datatype, [string]}
]}.

{mapping, "non_escaped.value", "non_escaped.value", [
  {datatype, [string]}
]}.

and the following .conf file:

escaped.value = '2f9sd79238-7_49%#sod7f9s87ee4'
non_escaped.value = 2f9sd79238749%#sod7f9s87ee4

Cuttlefish will now produce the following app config file:

[
  %% this value was cut off at the comment character, '#'
  {non_escaped,[{value, "2f9sd79238749%"}]},
  %% '#' was preserved in this value which used single quote escaping
  {escaped,[{value,"2f9sd79238-7_49%#sod7f9s87ee4"}]}
].

Limitations and Caveats

Single quotes are NOT
supported in these escaped values by design,
I do not thing that the \' escaping would
be worth our time. They are not particularly
common in Cuttlefish schemas according to Team RabbitMQ's
extensive experience with various configuration
files in the wild.

Closes #37.

References #31.

@lukebakken lukebakken self-assigned this Aug 5, 2024
@lukebakken lukebakken added this to the 3.3.0 milestone Aug 5, 2024
Currently Cuttlefish does not support string values that include the #
character.

This character is, however, used every so often in generated passwords,
identifiers and other machine-produced values.

This PR introduces an alternative value representation:

```
a.setting = 'sdkjf#hsdf$82836867#9237498'
```

...which allows such values to be escaped using single quotes. Single
quotes are NOT supported by these values by design, I do not thing that
the \' escaping would be worth our time.

This also drops an invalid UTF-8 input test that I could not get to
work. Somewhere inside Neotoma a returned error has turned into an
exception. Either way, the limited validation for valid UTF-8 characters
is still in place.

Closes #37.

References #31.

* Add an integration test for 'escaped values'
* One more test case for escaped values
* Fix `invalid_utf8_test` test
Copy link
Collaborator

@lukebakken lukebakken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can merge once CI passes. Thanks!

@michaelklishin michaelklishin merged commit ea862b4 into main Aug 5, 2024
4 checks passed
@michaelklishin michaelklishin deleted the mk-cuttlefish-37 branch August 5, 2024 15:25
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.

[Feature request] Provide a way to do character/string escaping
2 participants