chore: lint code blocks in docs with ESLint (#42113)
This commit is contained in:
parent
4e61f5b26f
commit
0d70389ccb
51 changed files with 308 additions and 34 deletions
|
|
@ -281,7 +281,8 @@ security-conscious developers might want to assume the very opposite.
|
|||
|
||||
```js title='main.js (Main Process)'
|
||||
const { session } = require('electron')
|
||||
const { URL } = require('url')
|
||||
|
||||
const { URL } = require('node:url')
|
||||
|
||||
session
|
||||
.fromPartition('some-partition')
|
||||
|
|
@ -611,9 +612,10 @@ sometimes be fooled - a `startsWith('https://example.com')` test would let
|
|||
`https://example.com.attacker.com` through.
|
||||
|
||||
```js title='main.js (Main Process)'
|
||||
const { URL } = require('url')
|
||||
const { app } = require('electron')
|
||||
|
||||
const { URL } = require('node:url')
|
||||
|
||||
app.on('web-contents-created', (event, contents) => {
|
||||
contents.on('will-navigate', (event, navigationUrl) => {
|
||||
const parsedUrl = new URL(navigationUrl)
|
||||
|
|
@ -690,12 +692,14 @@ leveraged to execute arbitrary commands.
|
|||
```js title='main.js (Main Process)' @ts-type={USER_CONTROLLED_DATA_HERE:string}
|
||||
// Bad
|
||||
const { shell } = require('electron')
|
||||
|
||||
shell.openExternal(USER_CONTROLLED_DATA_HERE)
|
||||
```
|
||||
|
||||
```js title='main.js (Main Process)'
|
||||
// Good
|
||||
const { shell } = require('electron')
|
||||
|
||||
shell.openExternal('https://example.com/index.html')
|
||||
```
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue