-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[🐛 Bug]: Return wrong value when using JavaScriptExecutor to execute decoding js function "atob" #13207
Comments
@Erix377, thank you for creating this issue. We will troubleshoot it as soon as we can. Info for maintainersTriage this issue by using labels.
If information is missing, add a helpful comment and then
If the issue is a question, add the
If the issue is valid but there is no time to troubleshoot it, consider adding the
If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C),
add the applicable
After troubleshooting the issue, please add the Thank you! |
Hmm, as far as I can tell, this should have been this way since the beginning (2009)... 3a13410#diff-f47940f927aeb054bf51538974a70205c603e484f5efe098e756bbe6535b8a6dR230-R236
I mean, this code was added before Java 7 was a thing, so I don't know if it is still true, or something we should be concerned about... Any Java experts chime in on this? @shs96c / @joerg1985 / @diemol |
@titusfortner @Erix377
|
@joerg1985 |
This conversion has always been there and/or was intended to always be there. I'm not sure how Selenium 3.2 would have skipped it, but if it did, it was a bug, and I don't think we have capacity to go back and figure out why. |
But the problem is that for the latest selenium, because it translate it to "\n" rather than "\r\n", it will cause the file generated based on the decoded data deprecated. Since, we found this issue when we try to generate a png file through writing the decoded data obtained from a canvas element. But the final generated PNG file is deprecated since the png format is not right due to the missing "/r". Thus, it is the new version which has the bug rather than the old version. |
I will say that other languages aren't making this change, so if it isn't currently a problem for Java maybe we shouldn't be doing it, or at least not doing it universally @shs96c I asked you about this a while back, can you chime in on the original reason for conversion? |
That's code from 2009, and that diff looks like it's something to do with the version of chromedriver we were working on. I'd have to go hunting for a deeper reason, so this is my working theory for now, but normalising line endings sounds like sending data back and forth between different platforms (macOS used |
@Erix377 do you want to PR an update removing the change? It should be handled in the driver, and the other bindings don't do it, so it *should be safe. 😂 |
This issue is looking for contributors. Please comment below or reach out to us through our IRC/Slack/Matrix channels if you are interested. |
I can remove the change. Let's see how safe this will be 🙃 |
What happened?
Running JavaScriptExecutor in Java code to excute the command "return atob('Rw0K')" in v3.2.0 will decode the string 'Rw0K' into 3 characters - ''G\r\n''. However, after upgrading to v4.13.0, it will decode this string into only 2 characters - which are 'G\n'. So basically, the '0K' string means to start a new line. However, in old version selenium, it will recognized as '\r\n' and for latest version, it will recognize as '\n'.
Since this incompatibility issue was found when we try to upgrade the selenium version from v3.2.0 to v4.13.0. Thus, it will cause some files' format doesn't match standard which leads to that file deprecated, like PNG file. Thus, I hope for the new selenium version, it can fix this incompatibility and when using JavaScriptExecutor to excute the command with 'atob' function, it can decode the encoded string which represents starting a new line back to "G\r\n", which is the same result as directly executing the command 'return atob('Rw0K')' web browser, like latest version chrome.
How can we reproduce the issue?
Relevant log output
Operating System
Mac, Windows, Linux
Selenium version
Java 4.13.0
What are the browser(s) and version(s) where you see this issue?
Chrome 119.0.6045.159 (Official Build) (arm64)
What are the browser driver(s) and version(s) where you see this issue?
geckodriver-v0.33.0-macos-aarch64, chromedriver
Are you using Selenium Grid?
no
The text was updated successfully, but these errors were encountered: