[java] fix downloading files from Grid (when file name contains space) - #16841
[java] fix downloading files from Grid (when file name contains space)#16841asolntsev wants to merge 1 commit into
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||||
35f982e to
aa83170
Compare
aa83170 to
693ad46
Compare
|
@titusfortner I recall why I wanted to pass file name in URL. |
... when file name contains space.
693ad46 to
8da593a
Compare
|
This PR was overseeded by #16844 |
User description
💥 What does this PR do?
Properly encode file name in URL
🔧 Implementation Notes
When adding value to URL, it has to be properly encoded.
It's not enough to just call
URLEncoder.encode(part), we also need to replace+characters by%20.When extracting file name from URL, we don't need to call
urlDecodebecause at that moment the name is already decoded (?).🔄 Types of changes
PR Type
Bug fix
Description
Fix file download from Grid when filename contains spaces or special characters
Properly encode filenames in URLs using %20 instead of + for spaces
Remove unnecessary URL decoding in filename extraction logic
Add comprehensive test coverage for various filename formats
Diagram Walkthrough
File Walkthrough
LocalNode.java
Simplify filename extraction and improve error messagesjava/src/org/openqa/selenium/grid/node/local/LocalNode.java
urlDecodeimportextractFileName()to return substring without decodingdownloadedFiles()return type fromListtoListFile::getNameStreamimport for stream operationsUrls.java
Fix URL encoding to use %20 for spacesjava/src/org/openqa/selenium/net/Urls.java
urlEncode()to replace+characters with%20RemoteWebDriverDownloadTest.java
Add parameterized tests for special character filenamesjava/test/org/openqa/selenium/grid/router/RemoteWebDriverDownloadTest.java
canDownloadFiles()from single test to parameterized testspaces)
canListDownloadedFiles()to verify 5 files with various formatsdownloadableFiles()method source for parameterized test dataParameterizedTestandMethodSourceannotationsdownload.html
Add test files with special characterscommon/src/web/downloads/download.html
file_ø.txt
Add test file with Norwegian charactercommon/src/web/downloads/file_ø.txt
file-с-русским-названием.txt
Add test file with Cyrillic characterscommon/src/web/downloads/file-с-русским-названием.txt
file 0 & _ ` `.txt
Add test file with spaces and special characterscommon/src/web/downloads/file 0 & _
.txt