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(hostname): fix handling of non-ASCII hostnames on Windows #3382

Merged
merged 2 commits into from
Nov 9, 2024

Conversation

cgutman
Copy link
Collaborator

@cgutman cgutman commented Nov 9, 2024

Description

boost::asio::ip::host_name() uses gethostname() under the hood on Windows, which returns characters in the OEM codepage (though Boost does not document this anywhere). This isn't what Sunshine is expecting, so it misinterprets the output as UTF-8 and writes potentially invalid characters into the /serverinfo response.

Other platforms use UTF-8 as their 8-bit string representation, so they should be fine to still call boost::asio::ip::host_name().

Screenshot

Issues Fixed or Closed

Fixes #3381

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Dependency update (updates to dependencies)
  • Documentation update (changes to documentation)
  • Repository update (changes to repository files, e.g. .github/...)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the in code docstring/documentation-blocks for new or existing methods/components

Copy link

codecov bot commented Nov 9, 2024

Codecov Report

Attention: Patch coverage is 40.00000% with 12 lines in your changes missing coverage. Please review.

Project coverage is 10.90%. Comparing base (d552073) to head (c44ca2d).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/platform/linux/misc.cpp 50.00% 3 Missing ⚠️
src/platform/macos/misc.mm 40.00% 2 Missing and 1 partial ⚠️
src/platform/windows/misc.cpp 50.00% 2 Missing and 1 partial ⚠️
src/config.cpp 0.00% 0 Missing and 1 partial ⚠️
src/platform/linux/publish.cpp 0.00% 1 Missing ⚠️
src/platform/windows/publish.cpp 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3382      +/-   ##
==========================================
- Coverage   11.05%   10.90%   -0.16%     
==========================================
  Files          99       99              
  Lines       17237    17247      +10     
  Branches     8036     8044       +8     
==========================================
- Hits         1905     1880      -25     
- Misses      12643    12809     +166     
+ Partials     2689     2558     -131     
Flag Coverage Δ
Linux 8.37% <42.85%> (+0.02%) ⬆️
Windows 5.31% <42.85%> (+0.08%) ⬆️
macOS-13 13.63% <33.33%> (+0.03%) ⬆️
macOS-14 ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/platform/common.h 32.25% <ø> (-1.79%) ⬇️
src/config.cpp 6.00% <0.00%> (ø)
src/platform/linux/publish.cpp 0.00% <0.00%> (ø)
src/platform/windows/publish.cpp 0.00% <0.00%> (ø)
src/platform/linux/misc.cpp 9.77% <50.00%> (+0.54%) ⬆️
src/platform/macos/misc.mm 9.39% <40.00%> (+0.65%) ⬆️
src/platform/windows/misc.cpp 3.73% <50.00%> (+1.11%) ⬆️

... and 25 files with indirect coverage changes

@cgutman
Copy link
Collaborator Author

cgutman commented Nov 9, 2024

Tested locally with hostname containing ü and confirmed that mDNS worked and the PC, iOS, and Android Moonlight clients displayed the names properly.

Copy link

sonarcloud bot commented Nov 9, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
1 New issue
1 New Code Smells (required ≤ 0)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

@cgutman cgutman merged commit fb1f5b5 into LizardByte:master Nov 9, 2024
33 of 36 checks passed
qiin2333 pushed a commit to qiin2333/Sunshine-Foundation that referenced this pull request Nov 13, 2024
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.

Unable to connect if PC hostname is UTF-16 encoded
2 participants