Closed Bug 697765 Opened 13 years ago Closed 13 years ago

Mozharness' download_file() method uses os.path.basename on urls

Categories

(Release Engineering :: Applications: MozharnessCore, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: ahal, Assigned: ahal)

Details

(Whiteboard: [mozharness])

Attachments

(1 file)

http://mxr.mozilla.org/build/source/mozharness/mozharness/base/script.py#145 1) This could lead to invalid file names if the url has parameters or anchors in it (e.g ? is reserved in windows). 2) I don't have a Windows environment handy, but I'm pretty sure this will just return the whole url on Windows. Instead use something similar to: import urlparse parsed = urlparse.urlsplit(url) if parsed.path != '': file_name = parsed.path.rstrip('/').rsplit('/',1)[1] else: # handle no path file_name = "default"
OS: Linux → All
Hardware: x86 → All
Whiteboard: [mozharness]
wfm. do you want to write a patch or should i?
I can do it, probably get around to it tomorrow.
Assignee: nobody → ahalberstadt
Status: NEW → ASSIGNED
Attachment #570286 - Flags: review?(aki)
Comment on attachment 570286 [details] [diff] [review] Patch 1.0 - Use urlparse instead of os.path.basename We found that the logic here doesn't work perfectly if: a) you are downloading from http://site.domain/ your file_name will be '' b) we may have issues if you're downloading from http://site.domain:portnum on windows Since we allow for specifying file_name when calling download_file(), and I doubt we'll ever really be downloading from the root of a domain on a regular basis, I'm going to r+ and land anyway.
Attachment #570286 - Flags: review?(aki) → review+
Comment on attachment 570286 [details] [diff] [review] Patch 1.0 - Use urlparse instead of os.path.basename http://hg.mozilla.org/build/mozharness/rev/ae752c6819bd
Attachment #570286 - Flags: checked-in+
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Product: mozilla.org → Release Engineering
Component: Other → Mozharness
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: