Repository: electron/electron (language: cpp)

Issue:
shell.showItemInFolder won't open Explorer if forward slashes are present in path
* Electron version: 1.7.10
* Operating system: Windows 10, build 1709

If a path contains forward slash(es) on Windows (e.g. `C:\some\app/index.html`), ~~showItemInFolder will open the containing directory but will not select the file.~~ In Electron 8.x and newer, showItemInFolder will not open an Explorer window at all if forward slashes are present in path.

### How to reproduce

https://github.com/YellowAfterlife/abug-electron-showItemInFolder-forward-slashes
```js
const electron = require('electron')
const app = electron.app
const path = require('path')
app.on('ready', () => {
	let test = path.join(__dirname, 'index.html')
	test = test.replace(/^(.+)\\(.+)$/, "$1/$2") // simulate a forward slash in path
	console.log(test)
	console.log(electron.shell.showItemInFolder(test))
	app.quit()
})
```

From what I've seen, no other shell functions show this kind of "partial success" behaviour while returning `true`.


Discussion / hints:
👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

To help make it easier for us to investigate your issue, please follow the [contributing guidelines](https://github.com/electron/electron/blob/master/CONTRIBUTING.md#submitting-issues).

Thank you for taking the time to report this issue and helping to make Electron better.

The version of Electron you reported this on has been superseded by newer releases. 

If you're still experiencing this issue in Electron v2.0.x or later, please add a comment specifying the version you're testing with and any other new information that a maintainer trying to reproduce the issue should know.

I'm setting the `blocked/need-info` label for the above reasons.

Thanks in advance! Your help is appreciated.
Still happens on 4.0.0-beta10 with same code.
I encountered the same issue but I couldn't figure out why it didn't select the file. Luckily google brought me here. Thanks for the heads up @YellowAfterlife 
`path.normalize`
Thank you for taking the time to report this issue and helping to make Electron better.

The version of Electron you reported this on has been superseded by newer releases. 

If you're still experiencing this issue in Electron 6.x.y or later, please add a comment specifying the version you're testing with and any other new information that a maintainer trying to reproduce the issue should know.

I'm setting the `blocked/need-info` label for the above reasons. This issue will be closed 7 days from now if there is no response.

Thanks in advance! Your help is appreciated.
It would appear that in 8.0.0-beta.7 Explorer straight up doesn't open if you have forward slashes in path.
Can confirm this happens in Electron `10.1.5`
As of right now Electron 9.0.0 still faces the same issue of the explorer straight up not opening
> `path.normalize`

Thank you @KavenWork this did the trick for me
> `path.normalize`

Thank you very very much, this indeed fixed my issue.
This issue has been automatically marked as stale. **If this issue is still affecting you, please leave any comment** (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the [latest version of Electron](https://www.electronjs.org/releases/stable) or in the [beta](https://www.electronjs.org/releases/beta)—please include it with your comment!
Still happens in v20.1.4, tested in Fiddle - further degradation from v8 (window doesn't open at all if slashes are malformed) remains.
```js
const {app, shell} = require('electron')
const path = require('path')

app.whenReady().then(() => {
	let test = path.join(__dirname, 'index.html')
	test = test.replace(/^(.+)\\(.+)$/, "$1/$2") // simulate a forward slash in path
	console.log(test)
	console.log(shell.showItemInFolder(test))
	app.quit()
})

```
confirmed on v22.1.0
This issue has been automatically marked as stale. **If this issue is still affecting you, please leave any comment** (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the [latest version of Electron](https://www.electronjs.org/releases/stable) or in the [beta](https://www.electronjs.org/releases/beta)—please include it with your comment!
Still there, tested on v25.0.0-beta-5 in Fiddle.
This issue has been automatically marked as stale. **If this issue is still affecting you, please leave any comment** (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the [latest version of Electron](https://www.electronjs.org/releases/stable) or in the [beta](https://www.electronjs.org/releases/beta)—please include it with your comment!
It is obviously tempting to just submit a PR with the one-line hack, but also this issue is now old enough to go to school so I'm interested to see how long it will last.
This issue has been automatically marked as stale. **If this issue is still affecting you, please leave any comment** (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the [latest version of Electron](https://www.electronjs.org/releases/stable) or in the [beta](https://www.electronjs.org/releases/beta)—please include it with your comment!
Still here as of v28.0.0-beta.4
This issue has been automatically marked as stale. **If this issue is still affecting you, please leave any comment** (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the [latest version of Electron](https://www.electronjs.org/releases/stable) or in the [beta](https://www.electronjs.org/releases/beta)—please include it with your comment!
Still here as of v29.0.0-beta.12

Fix patch:
diff --git a/shell/common/platform_util_win.cc b/shell/common/platform_util_win.cc
index a2deae69bf112..43684fc9e0efa 100644
--- a/shell/common/platform_util_win.cc
+++ b/shell/common/platform_util_win.cc
@@ -336,7 +336,8 @@ void ShowItemInFolder(const base::FilePath& full_path) {
   base::ThreadPool::CreateCOMSTATaskRunner(
       {base::MayBlock(), base::TaskPriority::USER_BLOCKING})
       ->PostTask(FROM_HERE,
-                 base::BindOnce(&ShowItemInFolderOnWorkerThread, full_path));
+                 base::BindOnce(&ShowItemInFolderOnWorkerThread,
+                                full_path.NormalizePathSeparators()));
 }
 
 void OpenPath(const base::FilePath& full_path, OpenCallback callback) {
@@ -344,9 +345,11 @@ void OpenPath(const base::FilePath& full_path, OpenCallback callback) {
 
   base::ThreadPool::CreateCOMSTATaskRunner(
       {base::MayBlock(), base::TaskPriority::USER_BLOCKING})
-      ->PostTaskAndReplyWithResult(FROM_HERE,
-                                   base::BindOnce(&OpenPathOnThread, full_path),
-                                   std::move(callback));
+      ->PostTaskAndReplyWithResult(
+          FROM_HERE,
+          base::BindOnce(&OpenPathOnThread,
+                         full_path.NormalizePathSeparators()),
+          std::move(callback));
 }
 
 void OpenExternal(const GURL& url,


Test patch: