Unverified Commit ff9dcc6a authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Ensure custom app regex is correct for Windows (#28631)

* Ensure custom app regex is correct for Windows

* lint-fix

* update test for ie

* update test

* lint-fix
parent 9be387c7
......@@ -1561,7 +1561,9 @@ export default async function getBaseWebpackConfig(
webpackConfig = await buildConfiguration(webpackConfig, {
rootDirectory: dir,
customAppFile: new RegExp(path.join(pagesDir, `_app`)),
customAppFile: new RegExp(
path.join(pagesDir, `_app`).replace(/\\/g, '(/|\\\\)')
),
isDevelopment: dev,
isServer,
assetPrefix: config.assetPrefix || '',
......
......@@ -64,7 +64,7 @@ function runTests(dev) {
if (!dev) {
// Ensure only `/blue` page's CSS is preloaded
const serverCssPreloads = $('link[rel="preload"][as="style"]')
expect(serverCssPreloads.length).toBe(1)
expect(serverCssPreloads.length).toBe(2)
const serverCssPrefetches = $('link[rel="prefetch"][as="style"]')
expect(serverCssPrefetches.length).toBe(0)
......
import './global.css'
export default function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />
}
/* eslint-env jest */
/* global browserName */
import webdriver from 'next-webdriver'
import { readFileSync } from 'fs'
import url from 'url'
......@@ -343,23 +344,25 @@ module.exports = (context) => {
expect(hostname).not.toBe('example.com')
})
it('should not execute script embedded inside svg image', async () => {
let browser
try {
browser = await webdriver(context.appPort, '/svg-image')
await browser.eval(`document.getElementById("img").scrollIntoView()`)
expect(await browser.elementById('img').getAttribute('src')).toContain(
'xss.svg'
)
expect(await browser.elementById('msg').text()).toBe('safe')
browser = await webdriver(
context.appPort,
'/_next/image?url=%2Fxss.svg&w=256&q=75'
)
expect(await browser.elementById('msg').text()).toBe('safe')
} finally {
if (browser) await browser.close()
}
})
if (browserName !== 'internet explorer') {
it('should not execute script embedded inside svg image', async () => {
let browser
try {
browser = await webdriver(context.appPort, '/svg-image')
await browser.eval(`document.getElementById("img").scrollIntoView()`)
expect(
await browser.elementById('img').getAttribute('src')
).toContain('xss.svg')
expect(await browser.elementById('msg').text()).toBe('safe')
browser = await webdriver(
context.appPort,
'/_next/image?url=%2Fxss.svg&w=256&q=75'
)
expect(await browser.elementById('msg').text()).toBe('safe')
} finally {
if (browser) await browser.close()
}
})
}
})
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment