1. 05 May, 2022 4 commits
    • Steven's avatar
      v12.1.7-canary.2 · cefb944e
      Steven authored
      cefb944e
    • JJ Kasper's avatar
      Tweak routing tests (#36667) · e8a8220d
      JJ Kasper authored
      Co-authored-by: 's avatarTim Neutkens <tim@timneutkens.nl>
      e8a8220d
    • Steven's avatar
      Add experimental wildcard `remotePatterns` config for upstream images (#36245) · da8d1984
      Steven authored
      ## Description 
      This PR implements a new configuration object in `next.config.js` called `experimental.images.remotePatterns`.
      
      This will eventually deprecate `images.domains` because it covers the same use cases and more by allowing wildcard pattern matching on `hostname` and `pathname` and also allows restricting `protocol` and `port`.
      
      ## Feature
      
      - [x] Implements an existing feature request.
      - [x] Related issues linked
      - [x] Unit tests added
      - [x] Integration tests added
      - [x] Documentation added
      - [x] Telemetry added. In case of a feature if it's used or not.
      - [x] Errors have helpful link attached, see `contributing.md`
      
      ## Related 
      
      - Fixes #27925 
      - Closes #18429 
      - Closes #18632
      - Closes #18730
      - Closes #27345
      da8d1984
    • Justin Goping's avatar
      Fix various Trusted Types violations without use of policy (#34726) · 0dd62111
      Justin Goping authored
      Linked to issue #32209.
      
      ## Feature
      
      - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
      - [x] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Documentation added
      - [ ] Telemetry added. In case of a feature if it's used or not.
      - [ ] Errors have helpful link attached, see `contributing.md`
      
      ## Documentation
      There are three Trusted Types violations that are fixed in this PR:
      ### 1. ban-element-innerhtml-assignments: maintain--tab-focus.ts
      The innerHTML assignment here is unsafe as a string is being used that could contain an XSS attack. The solution chosen was to replace the string containing HTML with programmatically-created DOM elements. This removes the Trusted Types violation as there is no longer a string passed in that can contain an XSS attack.
      
      Notes on solution:
      -  The `<svg>` tag is omitted completely since the original snippet returns fragment.firstChild.firstChild. The first firstChild omits the `<div>`, and the second firstChild omits the `<svg>`, so to remove unnecessary code the created elements start at the foreignObject level.
      -  The reason createElementNS is used instead of createElement is because the ‘foreignObject’ element is a separate namespace from the default HTML elements. The documentation for this command is found [here](https://developer.mozilla.org/en-US/docs/Web/API/Document/createElementNS).
      
      The code was tested to be equivalent by rendering both the original code and the re-written code in a browser to see if they evaluate to the same thing in the DOM. The DOM elements styles were then compared to ensure that they were identical.
      
      ### 2. ban-window-stringfunctiondef: packages/next/lib/recursive-delete.ts
      The setTimeout function caused a Trusted Types violation because if a string is passed in as the callback, XSS can occur. The solution to this problem is to ensure that only function callbacks can be passed to setTimeout. There is only one call to the sleep function and it does not involve a string callback, so this can be enforced without breaking the application logic. In the process of doing this, promisify has been removed and the promise has been created explicitly.
      
      The code was tested in a sample application to ensure it behaved as expected.
      
      ### 3. ban-window-stringfunctiondef: packages/next/client/dev/fouc.ts
      This file also uses setTimeout, so the call was wrapped in a `safeSetTimeout` call that specifies that the callback argument is not a string.
      0dd62111
  2. 04 May, 2022 3 commits
  3. 03 May, 2022 11 commits
    • Justin Goping's avatar
      Route Loader Trusted Types Violation Fix (#34730) · 44c89e50
      Justin Goping authored
      Linked to issue #32209.
      
      ## Feature
      
      - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
      - [x] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Documentation added
      - [ ] Telemetry added. In case of a feature if it's used or not.
      - [ ] Errors have helpful link attached, see `contributing.md`
      
      ## Documentation
      There is one tsec violation that is fixed in this PR:
      ### 1. ban-script-src-assignment: route-loader.ts
      XSS can occur with the line script.src = src in appendScript(src, script) if src can be controlled by a malicious user. From tracing through the code, it was determined that src comes from the function `getFilesForRoute(route)`. The behaviour of this function differs depending on the environment (development vs. production), but in both cases the function will construct strings that lead to valid file paths. These strings depend on two variables: `assetPrefix` and `route`, but due to the nature of the constructed strings it was determined that the scripts here are safe to use. Thus, the solution was to promote these strings to `TrustedScriptURL`s. This is the Trusted Types way of declaring that the script URL passed to the DOM sink is safe from DOM XSS attacks.
      
      To create a `TrustedScriptURL`, a policy needs to be created. This policy was put in its own file: `client/trusted-types.ts`. This policy has the name `nextjs`. If this name should be changed to something else, feel free to change it now. However, once it is released to the public and application developers begin using it, it may be harder to change the value since any application developers with a custom policy name allowlist would now need to update their `next.config.js` headers to allow this new name.
      
      The code was tested in a sample application to ensure it behaved as expected.
      44c89e50
    • Jiachi Liu's avatar
      fix: react root enabled properly in custom server (#36664) · ce6e8b56
      Jiachi Liu authored
      Fixes #36643
      
      ## Bug
      
      * hoist react dom choosing in client
      * also assign __NEXT_REACT_ROOT env in custom server
      
      - [x] Related issues linked using `fixes #number`
      - [x] Integration tests added
      - [ ] Errors have helpful link attached, see `contributing.md`
      ce6e8b56
    • Stig Kleppe-Jørgensen's avatar
      Improve wording (#36649) · 9cda84b4
      Stig Kleppe-Jørgensen authored
      
      
      ## Bug
      
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Errors have helpful link attached, see `contributing.md`
      
      ## Feature
      
      - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Documentation added
      - [ ] Telemetry added. In case of a feature if it's used or not.
      - [ ] Errors have helpful link attached, see `contributing.md`
      
      ## Documentation / Examples
      
      - [x] Improve wording
      - [ ] Make sure the linting passes by running `yarn lint`
      9cda84b4
    • JJ Kasper's avatar
      v12.1.7-canary.1 · 87529e98
      JJ Kasper authored
      87529e98
    • jpveilleux's avatar
      Added type to Page Component for TypeScript (#36608) · 0234e6d5
      jpveilleux authored
      * Added type to Page Component for TypeScript
      
      Following this tutorial, I noticed that TS was complaining that "getLayout" did not exist on Page. That is normal since Page is typed as NextPage. I simply exported the new type we create in "_App.tsx" and used it as the return type for Page. This will probably help others seeing that red in their editors and perhaps being confused.
      
      * Small linting change
      
      * Apply suggestions from code review
      
      * Update layouts.md
      
      * lint fix
      
      * update type
      Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
      0234e6d5
    • JJ Kasper's avatar
    • Tim Neutkens's avatar
      Enable disabled tests that pass (#36644) · fdc4ab88
      Tim Neutkens authored
      fdc4ab88
    • Tim Neutkens's avatar
      v12.1.7-canary.0 · b9bf2699
      Tim Neutkens authored
      b9bf2699
    • abdallah akrab's avatar
      docs: add jest-environment-jsdom package for Jest configuration (#36632) · 36825349
      abdallah akrab authored
      
      
      ## Documentation / Examples
      
      - [ ] Make sure the linting passes by running `yarn lint`
      
      Jest 28 does not include jest-environment-jsdom by default.
      
      following guide & running jest without jest-environment-jsdom causes the following  error:
      
      <img width="1598" alt="image" src="https://user-images.githubusercontent.com/37980706/166319065-2bc29bb4-7d56-43e5-b85d-5a7484f17b1b.png">
      
      36825349
    • Maria Violante's avatar
      Update buttercms example (#35436) · fec5318e
      Maria Violante authored
      * remove old buttercms project files
      
      * Updated .gitignore
      
      * Add new buttercms files
      
      * Add readme and remove name from package.json
      
      * fix linting error
      
      * Fix eslint
      
      * Update examples/cms-buttercms/.gitignore
      Co-authored-by: 's avatarLee Robinson <me@leerob.io>
      
      * renamed .env.sample > .env.local.example
      
      * remove dangerously allow svg
      
      * Update examples/cms-buttercms/package.json
      Co-authored-by: 's avatarLee Robinson <me@leerob.io>
      fec5318e
    • JJ Kasper's avatar
  4. 02 May, 2022 12 commits
  5. 01 May, 2022 3 commits
  6. 30 Apr, 2022 5 commits
  7. 29 Apr, 2022 2 commits