Skip to content

Commit

Permalink
Ensure custom app regex is correct for Windows (#28631)
Browse files Browse the repository at this point in the history
* Ensure custom app regex is correct for Windows

* lint-fix

* update test for ie

* update test

* lint-fix
  • Loading branch information
ijjk committed Aug 31, 2021
1 parent 9be387c commit ff9dcc6
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 20 deletions.
4 changes: 3 additions & 1 deletion packages/next/build/webpack-config.ts
Expand Up @@ -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 || '',
Expand Down
2 changes: 1 addition & 1 deletion test/integration/css-client-nav/test/index.test.js
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions test/integration/css-fixtures/multi-module/pages/_app.js
@@ -0,0 +1,5 @@
import './global.css'

export default function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />
}
3 changes: 3 additions & 0 deletions test/integration/css-fixtures/multi-module/pages/global.css
@@ -0,0 +1,3 @@
html {
background: grey;
}
39 changes: 21 additions & 18 deletions test/integration/production/test/security.js
@@ -1,4 +1,5 @@
/* eslint-env jest */
/* global browserName */
import webdriver from 'next-webdriver'
import { readFileSync } from 'fs'
import url from 'url'
Expand Down Expand Up @@ -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()
}
})
}
})
}

0 comments on commit ff9dcc6

Please sign in to comment.