-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validate and normalize hosted url. (#3030)
* Validate and normalize hosted url. We normalize the URL for a _hosted pub server_ to have no slash if the server is just a bare domain like `https://example.com`, but if the URL contains a path like `https://example.com/my-folder` then we always normalize to `https://example.com/my-folder/`. The reason for normalizing the URL is to improve consistency in `pubspec.lock` and make it easier to implement authentication without risks of being tricked by incorrect prefixes. Additionally, be normalizing to no slash for empty paths, and paths always ending in a slash when path is non-empty, we gain the benefit that relative URLs can always be constructed correctly using `hostedUrl.resolve('api/packages/$package')`. This additionally forbids a few edge cases such as: * querystring in the hosted URL (`https://server.com/?query`), * fragment in the hosted URL (`https://server.com/#hash`), * user-info in the hosted URL (`https://user:[email protected]`). These may have worked with previous versions of the `pub` client, but most likely the _querystring_ or _fragment_ would cause URLs to be garbled. Any user-info would likely have been ignored, this was not tested, any usage of these options is considered unlikely. Previously, `dart pub publish` would ignore the path in the hosted URL and always upload to `/api/packages/new`. This commit fixes this issue.
- Loading branch information
Showing
11 changed files
with
487 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.