Skip to content

Commit dcb360d

Browse files
committed
fix: limit URLs even shorter
Wine seems to empirically crash out on even shorter URLs, so limit it to 1500 as that seems fairly safe.
1 parent 089401c commit dcb360d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

engine/system/win/sys_main.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,13 @@ void PlatformOpenURL(const char* url)
413413
{
414414
#ifdef _WIN32
415415
// There is a surprisingly low limit for the maximum URL length that ShellExecute and browsers can open.
416-
// A common lower limit is 2083, so we'll refuse to open URLs smaller than this.
417-
// Wine crashes violently if this is violated, 2k should be a safe enough limit while still allowing rather long links.
418-
if (strlen(url) < 2048)
416+
// A common lower limit on Windows is 2083, so we'll definitely refuse to open URLs longer than that.
417+
// Wine on Linux has an indeterminate boundary above which it either crashes or silently does nothing,
418+
// one one system it landed at around 1575 bytes before failure, so put the limit somewhat below that.
419+
if (strlen(url) <= 1500)
420+
{
419421
ShellExecuteA(NULL, "open", url, NULL, NULL, SW_SHOWDEFAULT);
422+
}
420423
#else
421424
#warning LV: URL opening not implemented on this OS.
422425
// TODO(LV): Implement URL opening for other OSes.

0 commit comments

Comments
 (0)