selenium icon indicating copy to clipboard operation
selenium copied to clipboard

[🐛 Bug]: Firefox ProfilesIni.readProfiles() does not handle files written in UTF-16 (?)

Open numeralnathan opened this issue 2 years ago • 6 comments

What happened?

Firefox ProfilesIni.readProfiles() does not handle files written in UTF-16, I think. The following line ignores the encoding bytes at the front of the file.

https://github.com/SeleniumHQ/selenium/blob/d40b1a8504003abc71f7d5f2baedc99f51f8f65a/java/src/org/openqa/selenium/firefox/ProfilesIni.java#L60

How can we reproduce the issue?

The following code returns `null` even though the profile is correct.


   new ProfilesIni().
      getProfile("nathan");


### Relevant log output

```shell
Not applicable

Operating System

Windows 11

Selenium version

Java 3.141.59

What are the browser(s) and version(s) where you see this issue?

Firefox 97.0.2

What are the browser driver(s) and version(s) where you see this issue?

GeckDriver 0.30.0 win64

Are you using Selenium Grid?

No

numeralnathan avatar Mar 07 '22 17:03 numeralnathan

@numeralnathan, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

github-actions[bot] avatar Mar 07 '22 17:03 github-actions[bot]

Here is the profiles.ini file that causes the problem. I had to rename it to .txt because of Github.

profiles.txt

I am not sure downloading this file will preserve the character set encoding. The HTTP header content-type does not have a character set specified when downloading the file.

Notepad says this file is UTF-8 encoded. However, ProfileIni.readProfiles() is getting Strings with a space between each character. So, I suspect that the file is UTF-16.

numeralnathan avatar Mar 07 '22 17:03 numeralnathan

@numeralnathan apologies for the late reply. Just to confirm, is this issue happening in the latest Selenium release? (4.4.0).

diemol avatar Aug 17 '22 10:08 diemol

I don't know. I worked around the issue. I gave my profiles.txt file and the bug should be easy to reproduce.

numeralnathan avatar Aug 17 '22 14:08 numeralnathan

Right, but you were mentioning Selenium 3.x, and code has changed a lot between versions. Hence my question.

diemol avatar Aug 17 '22 14:08 diemol

@numeralnathan It seems utf16 encoding is lost when I download your profile.txt from github. Could you please upload a ZIP files containing your profiles.ini?

asolntsev avatar Aug 26 '22 11:08 asolntsev

I will close this but happy to reopen in case more information is provided.

diemol avatar Oct 17 '22 16:10 diemol

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Nov 17 '22 00:11 github-actions[bot]