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

Fix parsing of ports inside the URI #156

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

flokaiser
Copy link

without this change, urls like 5.my.s3.cluster were misinterpreted and
the '5' parsed as the port of the url.

Bug:

  • the getline() function puts the entire input string into the destination string, if the delimiter was not found. This leads to the entire host string being fed to the stoi() function to parse the port.

Fix:

  • If the portstr is equal to the host string, no ':port' was encountered. => Skip the parsing of the port

Copy link
Contributor

@kobalicek kobalicek left a comment

Choose a reason for hiding this comment

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

LGTM - needs one more review and possibly a future test case so this doesn't happen again.

Copy link
Member

@harshavardhana harshavardhana left a comment

Choose a reason for hiding this comment

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

Please also add a test

src/http.cc Outdated Show resolved Hide resolved
@flokaiser flokaiser force-pushed the fix_port_parsing branch 2 times, most recently from 038f54f to 6bbe61b Compare July 12, 2024 14:39
Florian Kaiser added 2 commits July 12, 2024 17:00
without this change, urls like 5.my.s3.cluster were misinterpreted and
  the '5' parsed as the port of the url.

Bug:
* the getline() function puts the entire input string into the
  destination string, if the delimiter was not found.
  This leads to the entire host string being fed to the stoi()
  function to parse the port.

Fix:
* applied suggestion by @balamurugana
this flag assignement was removed in:
  minio#111

I don't know if it was removed intentional, but without it
the BaseUrl.https flag only reflects the state of how BaseUrl was
constructed with.
@@ -162,6 +162,7 @@ BaseUrl::BaseUrl(std::string host, bool https, std::string region)
return;
}

this->https = url.https;
Copy link
Member

Choose a reason for hiding this comment

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

This is not correct. this->https is set in the constructor definition already.

Copy link
Author

Choose a reason for hiding this comment

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

I have seen that, but the Url class parses the schema to set the https flag in the url class that…
Correct me if I am wrong, but if I am constructing a u=BasicUrl("https://foo.bar", false)
Then u.https is false

Copy link
Member

Choose a reason for hiding this comment

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

Firstly BaseUrl accepts host. If URL is used, it takes only host and port. Secondly passed argument should override values. The current behavior is correct and this change is not correct.

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.

4 participants