Bug 20886 – std.process.browse does not work with URLs 256 characters or longer

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-05-30T21:32:40Z
Last change time
2021-04-22T10:44:38Z
Keywords
pull
Assigned to
No Owner
Creator
JR

Comments

Comment #0 by zorael — 2020-05-30T21:32:40Z
Manjaro/Arch x86_64, dmd 2.092.0. Supplying a long URL to std.process.browse seems to just make it execute xdg-open without passing the URL as an argument. (The URL I want to open is 397 characters.) import std; void main() { immutable url = "http://" ~ 'x'.repeat(249).array.idup; assert(url.length == 256); browse(url); } No browser window is opened, instead it outputs: > xdg-open -- opens a file or URL in the user's preferred > application > > Synopsis > > xdg-open { file | URL } > > xdg-open { --help | --manual | --version } > > Use 'man xdg-open' or 'xdg-open --manual' for additional info.
Comment #1 by aronrobert293 — 2021-04-20T16:33:22Z
I ran into this issue and it seems that is something wrong with this line > args[1] = = url.tempCString(); because after that line args[1] is ""
Comment #2 by dlang-bot — 2021-04-20T17:58:43Z
@MoonlightSentinel created dlang/phobos pull request #7988 "Fix 20886 - Retain tempCString buffer in browse" fixing this issue: - Fix 20886 - Retain tempCString buffer in browse The temporary buffer returned by `tempCString` was assigned to a `char*` and hence destroyed after the statement. This worked by accident for small URL's because the space was allocated on the stack and not overwritten before forking. https://github.com/dlang/phobos/pull/7988
Comment #3 by moonlightsentinel — 2021-04-20T18:03:33Z
Comment #4 by dlang-bot — 2021-04-22T10:44:38Z
dlang/phobos pull request #7988 "Fix 20886 - Retain tempCString buffer in browse" was merged into stable: - 08927149ccbb3a20fb7e97687065fe66a33e2cb8 by MoonlightSentinel: Fix 20886 - Retain tempCString buffer in browse The temporary buffer returned by `tempCString` was assigned to a `char*` and hence destroyed after the statement. This worked by accident for small URL's because the space was allocated on the stack and not overwritten before forking. https://github.com/dlang/phobos/pull/7988