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

net.urllib: Problematic parsing of consequtive slashes in URLs #22958

Open
billpcs opened this issue Nov 24, 2024 · 0 comments
Open

net.urllib: Problematic parsing of consequtive slashes in URLs #22958

billpcs opened this issue Nov 24, 2024 · 0 comments
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@billpcs
Copy link
Contributor

billpcs commented Nov 24, 2024

Describe the bug

I stumbled upon the issue when developing with my server with veb but the problem lies deeper, in net/urllib

The parsing logic does not handle well URLs that contain multiple consecutive slashes.

For example:

http://localhost:8080/another.html => OK
http://localhost:8080//another.html => erroneous parsing
http://localhost:8080//and///another.html => erroneous parsing

Reproduction Steps

One way to see it in action is this:

cd v/examples/veb/static_website
v run server.v

Go to http://localhost:8080/another.html (SUCCESS)
Go to http://localhost:8080//another.html (Error 404)

Expected Behavior

The same page loads regardless of the slashes

For example:

https://github.com/vlang/v/issues

is the same as

https://github.com/vlang//v//issues

Current Behavior

Error 404 or some other page is loaded (depending on if the result of the parsing points by luck to a different page)

Possible Solution

The function

fn parse_url(rawurl string, via_request bool) !URL

under vlib/net/urllib/urllib.v

does not handle via_request=false links correctly

In the above example it will parse "another.html" as the authority part (which is wrong)

Additional Information/Context

No response

V version

V 0.4.8 e4d24e8

Environment details (OS name and version, etc.)

V full version: V 0.4.8 e4d24e8
OS: linux, Ubuntu 22.04.5 LTS
Processor: 8 cpus, 64bit, little endian, Intel(R) Core(TM) i7-3630QM CPU @ 2.40GHz

getwd: /home/bill/Documents/opt/v/examples/veb/static_website
vexe: /home/bill/Documents/opt/v/v
vexe mtime: 2024-11-24 08:13:43

vroot: OK, value: /home/bill/Documents/opt/v
VMODULES: OK, value: /home/bill/.vmodules
VTMP: OK, value: /tmp/v_1000

Git version: git version 2.34.1
Git vroot status: 0.4.4-1912-ge4d24e89-dirty
.git/config present: true

CC version: cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
emcc version: N/A
thirdparty/tcc status: thirdparty-linux-amd64 0134e9b9

Huly®: V_0.6-21399

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@billpcs billpcs added the Bug This tag is applied to issues which reports bugs. label Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs.
Projects
None yet
Development

No branches or pull requests

1 participant