Fix #116280: bpy.ops.wm.url_open() cannot open file:/// #116295
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#116295
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "dfelinto/blender:fix-url-open"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This issue was introduced on
a15c637e63
.I tagged the two original reviewers of the PR as reviewer here. But the change is rather simple.
@ -1031,3 +1031,3 @@
# Make sure we have a scheme otherwise we can't parse the url.
if not url.startswith(("http://", "https://")):
if "://" not in url:
I think it's cleaner to check for the expected protocols.
E.g
@filedescriptor but where do we stop? how about gitea://, ftp://, ......
@dfelinto Well you can add all the protocols that make sense right? There aren't that many..
I think there's a bunch of issues with the surrounding code.
This is misleading, as this works fine:
You could argue that without scheme the string should go into the
netloc
field, but that's beside the point. Without schema, the URL can be parsed just fine.The second issue is the assumption that, if the URL doesn't start with
http://
orhttps://
that the addition of that string will produce a valid URL. This, again, is not true in general. Checking for://
helps, in that it's a more general check and will likely work better, but I don't think it's the right approach either as it can appear in any other part of the URL as well.Why not use
urlparse()
to do the parsing for us?this feels like a job a regex would excel at?
Wouldn't you want to condition that prefix on the parsed URL having an actual netloc as well? Otherwise your 'blender' example is going to turn the path of blender into http://blender where the path becomes the domain.
(I have no idea what this code is driven by, or how invalid the passed args could get, just noticed the potential.)
Incorporated @dr.sybren suggestion with some changes.
This confusion is what I was fearing when I wrote "You could argue that without scheme the string should go into the
netloc
field". For me (and AFAIK all webbrowsers),blender.org
is a valid URL and should be interpreted asnetloc
. That's not how Python'surlparse
function works, though.I suspect that there's only one use case for this particular piece of code, and that's turning a sheme-less URL into one with an explicit scheme. And so the logic of "if there is no scheme, chuck
https://
in front of it" seems pretty stable. I doubt there will be any scheme-relative (//blender.org/path
) URLs to handle.👍 LGTM!
I'm taking Sybren's review as final. Thanks everyone for pitching in