unjs / ipx

🖼️ High performance, secure and easy-to-use image optimizer.
MIT License
1.54k stars 61 forks source link

IPX crashes with ERR_INVALID_CHAR #42

Closed phof closed 2 years ago

phof commented 3 years ago

Steps to reproduce: 1) Start IPX, npx ipx 2) Submit a request such as GET /test/%00, or GET /test/%01, etc 3) IPX crashes with error:

node:internal/process/promises:246
          triggerUncaughtException(err, true /* fromPromise */);
          ^

TypeError [ERR_INVALID_CHAR]: Invalid character in statusMessage
    at new NodeError (node:internal/errors:363:5)
    at ServerResponse.writeHead (node:_http_server:323:11)
    at ServerResponse._implicitHeader (node:_http_server:266:8)
    at write_ (node:_http_outgoing:764:9)
    at ServerResponse.end (node:_http_outgoing:853:5)
    at /ipxissue/node_modules/ipx/dist/cli.js:543:11 {
  code: 'ERR_INVALID_CHAR'
}

This is impacting nuxt/image and thus any apps using it. I haven't had a chance to review IPX's source; will look tomorrow and submit a PR if I can get to the bottom of it.

phof commented 3 years ago

cc/ @pi0

pi0 commented 3 years ago

Hi @phof. Thanks for reporting the issue. Is there a chance you can also make a reproduction from this sandbox and submit to nuxt/image? This way we can check to fix all possible root causes.

BTW PR is always welcome! <3

pi0 commented 2 years ago

Hi. Finally coming back to this issue. It should be resolved in the next release with 1792d3aa2f4e572e0ca09cdac7272f60402cf3ea (and dee730856781739db2b4b09255c30fe0b4680dc6)

The similar reported issue https://github.com/nuxt/image/issues/376 with headers and file operator is also mitigated (there is no server error anymore).