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

feat(rule engine SQL): add an unescape function #12671

Conversation

kjellwinblad
Copy link
Contributor

@kjellwinblad kjellwinblad commented Mar 8, 2024

The added unescape function unescapes escape sequences, transforming them back to their represented characters. The following escape sequences are supported:

  • Standard C escape sequences:

    • \n for newline (LF)
    • \t for horizontal tab (HT)
    • \r for carriage return (CR)
    • \b for backspace (BS)
    • \f for formfeed (FF)
    • \v for vertical tab (VT)
    • \' for single quote (')
    • \" for double quote (")
    • \\ for backslash ()
    • \? for question mark (?)
    • \a for alert (bell, BEL)
  • Hexadecimal escape codes:

    • \xH... where H... is one or more hexadecimal digits (0-9, A-F, a-f), allowing for the encoding of arbitrary utf32 characters.

If an escape sequence is not recognized, or if the hexadecimal escape does not form a valid Unicode character, the function generates an exception.

Fixes:
#12460
https://emqx.atlassian.net/browse/EMQX-11847

Release version: v/e5.?

Summary

PR Checklist

Please convert it to a draft if any of the following conditions are not met. Reviewers may skip over until all the items are checked:

  • Added tests for the changes
  • [] Added property-based tests for code which performs user input validation
  • Changed lines covered in coverage report
  • Change log has been added to changes/(ce|ee)/(feat|perf|fix|breaking)-<PR-id>.en.md files
  • For internal contributor: there is a jira ticket to track this change
  • Created PR to emqx-docs if documentation update is required, or link to a follow-up jira ticket
  • [] Schema changes are backward compatible

The added `unescape` function unescapes escape sequences, transforming
them back to their represented characters. The following escape
sequences are supported:

- Standard C escape sequences:
  - `\n` for newline (LF)
  - `\t` for horizontal tab (HT)
  - `\r` for carriage return (CR)
  - `\b` for backspace (BS)
  - `\f` for formfeed (FF)
  - `\v` for vertical tab (VT)
  - `\'` for single quote (')
  - `\"` for double quote (")
  - `\\` for backslash (\)
  - `\?` for question mark (?)
  - `\a` for alert (bell, BEL)

- Hexadecimal escape codes:
  - `\xH...` where `H...` is one or more hexadecimal digits (0-9, A-F,
    a-f), allowing for the encoding of arbitrary utf32 characters.

If an escape sequence is not recognized, or if the hexadecimal escape
does not form a valid Unicode character, the function generates an
exception.

Fixes:
emqx#12460
https://emqx.atlassian.net/browse/EMQX-11847
@kjellwinblad kjellwinblad requested a review from a team as a code owner March 8, 2024 11:05
@kjellwinblad
Copy link
Contributor Author

Jira issue for adding documentation:

https://emqx.atlassian.net/browse/EMQX-11969

@zmstone zmstone merged commit 68682c4 into emqx:master Mar 8, 2024
166 checks passed
@emqxqa
Copy link

emqxqa commented May 8, 2024

Test Execution

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.

4 participants