Skip to content

PlatformOpenURL's 1500-char Wine guard is far too conservative on modern Wine (measured limit: 32676), and failures are silent #106

Description

@Lowtrixx

Summary

PlatformOpenURL (added in #70) refuses any URL longer than 1500 bytes when running under Wine on Linux/macOS:

// engine/system/win/sys_main.cpp
if ((wineHost == "Linux" || wineHost == "Darwin") && strlen(url) > 1500)
    return AllocString("Did not open URL, length likely too long for the OS.");

On current Wine this threshold is about 21x too strict, and because no Lua caller inspects the returned string, the user sees nothing at all — the button appears dead.

Impact

Most visible in the timeless jewel search (Classes/TreeTab.lua, "Open Next Trade URL"). A search over ~11 seeds produces a trade URL of ~1800 characters, which is silently dropped. The following line, Copy(url), still runs, so the URL lands on the clipboard with no indication that the browser was never invoked.

Measurements

Environment: Arch Linux (kernel 6.18), Wine 11.13 (64-bit prefix), Hyprland/Wayland, xdg-open -> Brave.

Test binary calling exactly what PlatformOpenURL calls — ShellExecuteA(NULL, "open", url, NULL, NULL, SW_SHOWDEFAULT) — with a stub xdg-open on PATH to record the URL actually delivered:

URL length Result
1823 (real trade URL) delivered, browser opened
4000 / 8000 / 16000 / 30000 delivered, browser opened
32676 delivered — last working length
32677 fails: err:environ:build_command_line command line too long

The cliff is the Windows 32767-char command-line limit, minus ~91 chars of overhead for "C:\windows\system32\winebrowser.exe" "<url>". It is not a crash: ShellExecuteA still returns 33, the child is simply never created — so the failure is silent at the API level too.

Note that the effective headroom depends on the length of the registered http\shell\open\command, so a fixed limit somewhat below 32767 is still reasonable.

One genuine long-URL crash does exist on this Wine version, but on a different path: wine start <url> segfaults (c0000005) above roughly 300 chars. ShellExecuteA is unaffected. If #70's original crash report came from a start.exe-based launcher, that would explain the very low bound chosen at the time.

Suggested fix

  1. Raise the limit to something near the real constraint (e.g. 32000), or compute it as 32767 - strlen(handler command).
  2. Surface the failure. Since no caller checks the return value today, either log it via ConPrintf inside PlatformOpenURL, or have callers such as TreeTab.lua:2173 show the message when a non-nil string comes back. As-is, a user on Linux gets a button that does nothing with no diagnostic.

Happy to open a PR for either part.

Workaround for other Linux users

The full URL is still copied to the clipboard by TreeTab.lua:2174, so pasting it manually works. Selecting a smaller row range before pressing the button also keeps the URL under 1500.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions