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

Allow relative URLs in the redirect location header. #229

Merged
merged 5 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions safe_url_check/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v.1.1.2
* Allow relative URLs in the redirect `location` header.

## v1.1.1
* Added `topics` to `pubspec.yaml`.

Expand Down
4 changes: 3 additions & 1 deletion safe_url_check/lib/safe_url_check.dart
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,10 @@ Future<bool> _safeUrlCheck(
if (response.isRedirect &&
response.headers[HttpHeaders.locationHeader]!.isNotEmpty &&
maxRedirects > 0) {
final loc = Uri.parse(response.headers[HttpHeaders.locationHeader]![0]);
final nextUri = loc.hasScheme ? loc : url.resolveUri(loc);
isoos marked this conversation as resolved.
Show resolved Hide resolved
return _safeUrlCheck(
Uri.parse(response.headers[HttpHeaders.locationHeader]![0]),
nextUri,
maxRedirects - 1,
client,
userAgent,
Expand Down
2 changes: 1 addition & 1 deletion safe_url_check/lib/src/version.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions safe_url_check/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: safe_url_check
version: 1.1.1
version: 1.1.2
description: >-
Check if an untrusted URL is broken, without allowing connections to a private
IP address.
Expand All @@ -18,6 +18,6 @@ dependencies:

dev_dependencies:
test: ^1.5.1
lints: ^2.0.1
lints: ^3.0.0
build_runner: ^2.3.3
build_version: ^2.0.1