rabbitmq_tracing: explicitly specify UTF-8 encoding for served trace files (backport #14966) (backport #14970) #14972
+49
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Set charset=utf-8 in Content-Type header to ensure proper display of Cyrillic and other Unicode characters in browsers.
Fixes #13952
Proposed Changes
This PR fixes incorrect encoding display for Cyrillic and other Unicode characters when viewing trace log files through the RabbitMQ management UI. The issue was that browsers were misinterpreting UTF-8 encoded content as Latin-1 when no charset was specified in the
Content-Typeheader.Why this change:
rabbit_tracing_consumer(usingio_lib:formatandrabbit_json:encode)Привет мир→Привет мир)charset=utf-8to theContent-Typeheader ensures browsers correctly interpret the file contentSolution chosen:
The original issue suggested a client-side JavaScript solution, but we implemented a server-side fix instead because:
about:blank)Types of Changes
What types of changes does your code introduce to this project?
Put an
xin the boxes that applyChecklist
Put an
xin the boxes that apply.You can also fill these out after creating the PR.
This is simply a reminder of what we are going to look for before merging your code.
CONTRIBUTING.mddocumentFurther Comments
Changes made:
deps/rabbitmq_tracing/src/rabbit_tracing_wm_file.erlto setContent-Type: text/plain; charset=utf-8header inserve/2trace_file_content_type_testindeps/rabbitmq_tracing/test/rabbit_tracing_SUITE.erlto verify the Content-Type header includes charsetWhy this is safe:
text/plain)rabbit_mgmt_oauth_bootstrap.erlsetstext/javascript; charset=utf-8)Testing:
text/plainandcharset=utf-8Before the fix:

After the fix:

This is an automatic backport of pull request #14966 done by [Mergify](https://mergify.com).
This is an automatic backport of pull request #14970 done by [Mergify](https://mergify.com).