-
-
Notifications
You must be signed in to change notification settings - Fork 17
BUGFIX: Compare hosts when checking if target and source are the same #106
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
0050ae1
348ab86
638c49b
88a8607
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,15 +90,14 @@ export class RedirectForm extends PureComponent<RedirectFormProps, RedirectFormS | |
| // Replace a single asterisk with an empty value to match any domain | ||
| host = host && host.trim() === '*' ? '' : host; | ||
|
|
||
| if (!host || host === location.host) { | ||
| const parsedSourceUrl: URL = UrlUtil.parseURL(sourceUriPath, location.origin); | ||
| const parsedTargetUrl: URL = UrlUtil.parseURL(targetUriPath, location.origin); | ||
| if (parsedSourceUrl.pathname === parsedTargetUrl.pathname) { | ||
| notificationHelper.warning( | ||
| translate('error.sameSourceAndTarget', 'The source and target paths cannot be the same') | ||
| ); | ||
| return; | ||
| } | ||
| const parsedSourceUrl: URL = UrlUtil.parseURL(sourceUriPath, location.origin); | ||
| const parsedTargetUrl: URL = UrlUtil.parseURL(targetUriPath, location.origin); | ||
|
|
||
| if ((!host || host === parsedTargetUrl.host) && parsedSourceUrl.pathname === parsedTargetUrl.pathname) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't it be instead:
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, this probably got lost when I rebased something. Changed it |
||
| notificationHelper.warning( | ||
| translate('error.sameSourceAndTarget', 'The source and target paths cannot be the same') | ||
| ); | ||
| return; | ||
| } | ||
|
|
||
| const validStartDateTimeString = | ||
|
|
||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
hostis used to determine whether a redirect is triggered in the middleware. So it has no relation to the target. IMO this part of the change is incorrect.I think rather the
targetUriPathshould be checked twice in case one time it was given without host and one time with a host.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand.
$redirect->getHost() === $hostwill always be true, so I'm not sure if it's the correct check in this case.Can you tell me how you would've solved it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case the host comparison compares to equal, which is true and fine.
$targetUriPathcan be a full url or just a path.So you have to turn the existing and the new
$targetUriPathinto an absolute url for comparison and then check.