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

fix: Not fully compatible with [email protected], causing program errors #5999

Closed
wll8 opened this issue Sep 30, 2024 · 2 comments
Closed

Comments

@wll8
Copy link

wll8 commented Sep 30, 2024

env

see:

Code Analysis:

see:

step:

  • methods includes bind.
  • Therefore, app has a bind function.
  • The bind function can accept this, which is an object (path).
  • However, in the bind function, this._router.route(path) receives this object.
  • This object is passed to path-to-regexp.
  • In path-to-regexp v0.1.7, the object is converted to a string without causing an error.
  • In path-to-regexp v0.1.10, encountering an object can cause the program to crash.
  • This is the reason for the program crash after the update.

The version that found the problem was 0.1.10, but this error was thrown in 0.1.11.

  if (typeof path !== 'string') {
    throw new TypeError('path must be a string, array of strings, or regular expression');
  }

imgA:

image

imgB:

image

In imgA, httpolyglot passed an object, which was concatenated into a string in path-to-regexp 0.1.7, and the program had no errors. However, in later versions of path-to-regexp, my use case ran into errors because the object could not be handled "friendly".

If you decide to upgrade path-to-regexp, should you keep old programs compatible without causing them to crash? What is the right way to do it? Do you not handle the app passed in when bind?

@NewEraCracker
Copy link

This is connected with: #5955 and #5975

Please check if any of the comments on #5955 can help you.

My two cents.

@wll8
Copy link
Author

wll8 commented Oct 1, 2024

Deal with issues in a centralized location. #5955 and #5975

@wll8 wll8 closed this as completed Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants