Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure custom app regex is correct for Windows #28631

Merged
merged 5 commits into from Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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()
}
})
}
})
}