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

Url of adlist can contain userinfo (basicauth) #1683

Merged
merged 2 commits into from
Jan 13, 2021

Conversation

mdujava
Copy link

@mdujava mdujava commented Jan 5, 2021

By submitting this pull request, I confirm the following:

  • I have read and understood the contributors guide, as well as this entire template.
  • I have made only one major change in my proposed changes.
  • I have commented my proposed changes within the code.
  • I have tested my proposed changes.
  • I am willing to help maintain this change if there are issues with it later.
  • I give this submission freely and claim no ownership.
  • It is compatible with the EUPL 1.2 license
  • I have squashed any insignificant commits. (git rebase)
  • I have Signed Off all commits. (git commit --signoff)

What does this PR aim to accomplish?:

This PR is admin page side of fix for parsing adlist urls, pi-hole/pi-hole#3912

How does this PR accomplish the above?:

Similar to the pi-hole code, before validation against regex, char @ is removed if it is inside of authority section of url. Then already existing regex is used to check if only allowed chars are present in url.

What documentation changes (if any) are needed to support this PR?:

No documentation is needed as this is only change of check on backend side, no user facing change.

Web side of fix pi-hole/pi-hole#3912

Signed-off-by: Matej Dujava <mdujava@kocurkovo.cz>
if(preg_match("/[^a-zA-Z0-9:\/?&%=~._()-;]/", $address) !== 0) {
// this will remove first @ that is after schema and before domain
 // $1 is optional schema, $2 is userinfo
$check_address = preg_replace("|([^:/]*://)?([^/]+)@|", "$1$2", $address, 1);
Copy link
Author

@mdujava mdujava Jan 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

phpstan error: looks like False positive, changing comment to multi-line form is fixing the error.

@PromoFaux PromoFaux merged commit 952c157 into pi-hole:devel Jan 13, 2021
@mdujava mdujava deleted the basic_auth branch January 14, 2021 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants