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

[FIX] serveResources: Correctly encode non UTF-8 resources #201

Merged
merged 2 commits into from
Jun 24, 2019

Conversation

RandomByte
Copy link
Member

The replaceStream module converts all string it processes to UTF-8.
Therefore, stop using it for strings that are not UTF-8 encoded.

Resolves https://github.com/SAP/ui5-server/issues/196

The replaceStream module converts all string it processes to UTF-8.
Therefore, stop using it for strings that are not UTF-8 encoded.

Resolves https://github.com/SAP/ui5-server/issues/196
@coveralls
Copy link

coveralls commented Jun 18, 2019

Coverage Status

Coverage increased (+0.02%) to 93.309% when pulling a66337d on handle-non-utf8-encoded-resources into 840dfb9 on master.

codeworrior
codeworrior previously approved these changes Jun 18, 2019
Copy link
Member

@codeworrior codeworrior left a comment

Choose a reason for hiding this comment

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

LGTM.

"Correct content type and charset");

t.deepEqual(res.body.toString("latin1"), "showHelloButtonText=Say ä!", "Correct response");
// Because it took so long to figure this out I keep the below line. It is equivalent to the deepEqual above
Copy link
Member

Choose a reason for hiding this comment

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

This comment makes me curious: what did you want to achieve with that line?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, now it seems pretty clear. But I first struggled converting res.text (without calling .responseType("arraybuffer") form latin1 to UTF-8. I did not get that working.

I still find it a bit confusing that I have a raw Buffer, containing some latin1 encoded characters, that I can only convert to a UTF-8 string by calling .toString("latin1").

@RandomByte RandomByte force-pushed the handle-non-utf8-encoded-resources branch from 5eb629e to a66337d Compare June 19, 2019 10:56
@RandomByte RandomByte requested review from codeworrior and matz3 June 24, 2019 11:28
@RandomByte RandomByte merged commit 8ec1a7e into master Jun 24, 2019
@RandomByte RandomByte deleted the handle-non-utf8-encoded-resources branch June 24, 2019 17:14
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.

i18n.properties responds with wrong charset
4 participants