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