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

util: fix Latin1 decoding to return string output #56222

Merged
merged 7 commits into from
Dec 14, 2024

Conversation

mertcanaltin
Copy link
Member

@mertcanaltin mertcanaltin commented Dec 11, 2024

returned a string instead of a buffer

Fixes: #56219

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Dec 11, 2024
@aduh95
Copy link
Contributor

aduh95 commented Dec 11, 2024

Can you add a test?

@mertcanaltin
Copy link
Member Author

Can you add a test?

added to cctest

@aduh95
Copy link
Contributor

aduh95 commented Dec 11, 2024

Could we have a test with TextDecoder to validate the reported issue is fixed and won't come back?

@mertcanaltin
Copy link
Member Author

Could we have a test with TextDecoder to validate the reported issue is fixed and won't come back?

Yes, that's right. I'm sorry, I was focusing on the cctest.

@mertcanaltin mertcanaltin requested a review from aduh95 December 11, 2024 10:10
@aduh95 aduh95 added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Dec 11, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Dec 11, 2024
@nodejs-github-bot
Copy link
Collaborator

Copy link

codecov bot commented Dec 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.54%. Comparing base (2063245) to head (e8cf59a).
Report is 35 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #56222      +/-   ##
==========================================
+ Coverage   88.52%   88.54%   +0.01%     
==========================================
  Files         657      657              
  Lines      189860   189972     +112     
  Branches    36448    36483      +35     
==========================================
+ Hits       168080   168206     +126     
+ Misses      14978    14952      -26     
- Partials     6802     6814      +12     
Files with missing lines Coverage Δ
src/encoding_binding.cc 79.09% <100.00%> (+7.66%) ⬆️

... and 34 files with indirect coverage changes

Copy link
Member

@lemire lemire left a comment

Choose a reason for hiding this comment

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

To my knowledge, it is the first TextDecoder test for Latin1 that we have! So that's progress. :-)

@mertcanaltin
Copy link
Member Author

To my knowledge, it is the first TextDecoder test for Latin1 that we have! So that's progress. :-)

I'm so happy to hear that! 🚀

@anonrig
Copy link
Member

anonrig commented Dec 11, 2024

Good work!

@aduh95
Copy link
Contributor

aduh95 commented Dec 11, 2024

Related test failure on build compiled --without-intl:

not ok 3162 parallel/test-util-text-decoder
  ---
  duration_ms: 125.69700
  severity: fail
  exitcode: 1
  stack: |-
    ✖ TextDecoder correctly decodes windows-1252 encoded data (1.319017ms)
      RangeError [ERR_ENCODING_NOT_SUPPORTED]: The "windows-1252" encoding is not supported
          at new TextDecoder (node:internal/encoding:490:15)
          at TestContext.<anonymous> (/home/iojs/build/workspace/node-test-commit-linux-containered/test/parallel/test-util-text-decoder.js:13:19)
          at Test.runInAsyncScope (node:async_hooks:211:14)
          at Test.run (node:internal/test_runner/test:931:25)
          at Test.start (node:internal/test_runner/test:829:17)
          at startSubtestAfterBootstrap (node:internal/test_runner/harness:297:17) {
        code: 'ERR_ENCODING_NOT_SUPPORTED'
      }
    
    ℹ tests 1
    ℹ suites 0
    ℹ pass 0
    ℹ fail 1
    ℹ cancelled 0
    ℹ skipped 0
    ℹ todo 0
    ℹ duration_ms 12.534744
    
    ✖ failing tests:
    
    test at test/parallel/test-util-text-decoder.js:8:1
    ✖ TextDecoder correctly decodes windows-1252 encoded data (1.319017ms)
      RangeError [ERR_ENCODING_NOT_SUPPORTED]: The "windows-1252" encoding is not supported
          at new TextDecoder (node:internal/encoding:490:15)
          at TestContext.<anonymous> (/home/iojs/build/workspace/node-test-commit-linux-containered/test/parallel/test-util-text-decoder.js:13:19)
          at Test.runInAsyncScope (node:async_hooks:211:14)
          at Test.run (node:internal/test_runner/test:931:25)
          at Test.start (node:internal/test_runner/test:829:17)
          at startSubtestAfterBootstrap (node:internal/test_runner/harness:297:17) {
        code: 'ERR_ENCODING_NOT_SUPPORTED'
      }
  ...

@mertcanaltin
Copy link
Member Author

mertcanaltin commented Dec 11, 2024

I'm considering whether skipping the test in such scenarios would be the correct approach.

Alternatively, I managed to implement a custom solution to decode the sequence myself, but I’m unsure if this is a reliable or sustainable approach. Do you have any suggestions or best practices for handling this situation?

Thank you in advance for your guidance!

@BridgeAR
Copy link
Member

For this specific case, it's probably fine to skip the test for builds without intl. We could theoretically implement further support, but I believe that is not currently necessary, as it has not been requested.

@mertcanaltin
Copy link
Member Author

For this specific case, it's probably fine to skip the test for builds without intl. We could theoretically implement further support, but I believe that is not currently necessary, as it has not been requested.

I passed the test with the condition !common.hasIntl

@aduh95 aduh95 added the request-ci Add this label to start a Jenkins CI on a PR. label Dec 11, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Dec 11, 2024
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@anonrig anonrig added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Dec 14, 2024
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Dec 14, 2024
@nodejs-github-bot nodejs-github-bot merged commit e7a397a into nodejs:main Dec 14, 2024
64 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in e7a397a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TextDecoder regressed for ascii, windows-1252, ... encodings in v23.4.0
7 participants