ropensci / RSelenium

An R client for Selenium Remote WebDriver
https://docs.ropensci.org/RSelenium
341 stars 81 forks source link

makePrefjs doesn't properly escape strings #200

Open AshesITR opened 5 years ago

AshesITR commented 5 years ago

This piece of code isn't enough to provide valid JS for character options:

https://github.com/ropensci/RSelenium/blob/c11dd6922aedd654a2680e7737c63ce534e7c9ce/R/util.R#L288

This bug manifests e.g. when setting the download directory in windows:

RSelenium::makeFirefoxProfile(list(browser.download.dir = "C:\\Downloads"))

The result is that the preferences aren't correctly set up, as you can manually check in the Selenium window by examining about:config.

I currently work around this issue by escaping the string for use in JS source code before passing it to RSelenium, but it would be nice if that weren't necessary.


Possible remedy: Using deparse(unname(...)) instead of dQuote should work. I have not tested this though.
Here is some info about what needs escaping: https://www.freeformatter.com/javascript-escape.html

brshallo commented 5 years ago

Perhaps this is causing the problems indicated here: https://stackoverflow.com/questions/35551711/specify-download-folder-in-rselenium-does-not-work

And here: https://stackoverflow.com/questions/53091783/cant-set-download-directory-with-rselenium-firefox