-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Fixes an exception in AMQP 0-9-1 exception (error) generator when input data includes non-ASCII characters #12888
Fixes an exception in AMQP 0-9-1 exception (error) generator when input data includes non-ASCII characters #12888
Conversation
`rabbit_binary_generator:map_exception/3` will crash when there are unicode characters in the `explaination` field of `Reason#amqp_error` parameter. The explaination string (list) is assumed to be ascii, with each character/member in the range of a byte. Any unicode characters in the string will trigger `badarg` crash of `list_to_binary/1` in `rabbit_binary_generator:amqp_exception_explanation/2`. Amqp091 shovel crash due to this is reported, rabbitmq#12874 When a queue as shovel source/destination does not exist, and its name contains non-ascii characters, the explaination of amqp_error will be like `no queue non_ascii_name_😍 in vhost /`. It will subsequently crash and even affect management console. To fix this, `unicode:characters_to_binary/1` is used instead of `list_to_binary/1`, and unicode-safe truncation of long explaination with `io_lib:format/3` chars_limit replaces direct bytes truncation.
@bpint Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@bpint Thank you for signing the Contributor License Agreement! |
(cherry picked from commit 9b19539)
#12889 is in. @bpint in some 8-10 minutes a new
|
Curiously, one of the workflows failed for the first time in weeks, for a reason that has nothing to do with this PR. I have restarted it. |
There you go, |
@michaelklishin thanks! i have tried the following shovel. it declared 2 non-existing queues and work well. {
"ack-mode": "on-confirm",
"dest-add-forward-headers": false,
"dest-protocol": "amqp091",
"dest-queue": "кролик 🐰",
"dest-uri": "amqp://",
"src-delete-after": "never",
"src-protocol": "amqp091",
"src-queue": "non_ascii_name_😍_你好",
"src-uri": "amqp://"
}
|
Excellent. |
Proposed Changes
rabbit_binary_generator:map_exception/3
will crash when there are unicode characters in theexplanation
field ofReason#amqp_error
parameter. The explanation string (list) is assumed to be ascii, with each character/member in the range of a byte. Any unicode characters in the string will triggerbadarg
crash oflist_to_binary/1
inrabbit_binary_generator:amqp_exception_explanation/2
.Amqp091 shovel crash due to this is reported, #12874
When a queue as shovel source/destination does not exist, and its name contains non-ascii characters, the explanation of amqp_error will be like
no queue non_ascii_name_😍 in vhost /
. It will subsequently crash and even affect management console.To fix this,
unicode:characters_to_binary/1
is used instead oflist_to_binary/1
, and unicode-safe truncation of long explanation withio_lib:format/3
chars_limit replaces direct bytes truncation.Types of Changes
What types of changes does your code introduce to this project?
Put an
x
in the boxes that applyChecklist
Put an
x
in the boxes that apply.You can also fill these out after creating the PR.
If you're unsure about any of them, don't hesitate to ask on the mailing list.
We're here to help!
This is simply a reminder of what we are going to look for before merging your code.
CONTRIBUTING.md
document