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 bracket IPv6 address format inside IPAdress Normalizer #13327

Merged
merged 1 commit into from
Mar 6, 2019

Conversation

tcitworld
Copy link
Member

@tcitworld tcitworld commented Jan 3, 2019

Fix #13943

When run with php's build-in server (for instance on localhost:8080), IP provided through $this->server['REMOTE_ADDR'] is [::1], which is not an acceptable format for \inet_pton.

I didn't dig why I've got an IPv6 localhost or anything, but I guess it's still valid.

This removes the brackets if there's any.

When run with php's build-in server (for instance on localhost:8080), IP provided through $this->server['REMOTE_ADDR'] is [::1], which is not an acceptable format for \inet_pton. This removes the brackets if there's any.

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
@tcitworld tcitworld added 3. to review Waiting for reviews security php Pull requests that update Php code labels Jan 3, 2019
@@ -68,6 +68,9 @@ private function getIPv4Subnet(string $ip, int $maskBits = 32): string {
* @return string
*/
private function getIPv6Subnet(string $ip, int $maskBits = 48): string {
if ($ip[0] === '[' && $ip[-1] === ']') { // If IP is with brackets, for example [::1]
Copy link
Contributor

Choose a reason for hiding this comment

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

trim($ip, '[]')) would also work.

@kesselb kesselb added this to the Nextcloud 16 milestone Feb 19, 2019
@MorrisJobke MorrisJobke mentioned this pull request Mar 4, 2019
45 tasks
Copy link
Member

@MorrisJobke MorrisJobke left a comment

Choose a reason for hiding this comment

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

Code makes sense 👍

@MorrisJobke
Copy link
Member

@ChristophWurst Mind to review this one?

Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

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

Makes sense! Thank you!

@ChristophWurst ChristophWurst added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Mar 6, 2019
@MorrisJobke MorrisJobke merged commit d004164 into master Mar 6, 2019
@MorrisJobke MorrisJobke deleted the allow-bracket-notation-for-remove-ipv6-address branch March 6, 2019 09:34
@MorrisJobke MorrisJobke mentioned this pull request Mar 6, 2019
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish php Pull requests that update Php code security
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants