[From nobody Thu Oct  8 22:01:13 2026
Received: (at submit) by bugs.debian.org; 7 Oct 2026 11:39:39 +0000
X-Spam-Checker-Version: SpamAssassin 4.0.1-bugs.debian.org_2005_01_02
 (2024-03-25) on buxtehude.debian.org
X-Spam-Level: 
X-Spam-Status: No, score=-27.7 required=4.0 tests=BAYES_00,
 BODY_INCLUDES_CONTROL_AFFECTS,BODY_INCLUDES_PACKAGE,FOURLA,
 FROMDEVELOPER,HAS_PACKAGE,HEADER_FROM_DIFFERENT_DOMAINS,MD5_SHA1_SUM,
 SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no
 version=4.0.1-bugs.debian.org_2005_01_02
X-Spam-Bayes: score:0.0000 Tokens: new, 40; hammy, 122; neutral, 39; spammy,
 0. spammytokens: hammytokens:0.000-+--Maintainer,
 0.000-+--Hx-authordomain:debian.org, 0.000-+--backporting,
 0.000-+--UD:github.com, 0.000-+--githubcom
Return-path: &lt;jordi@oskuro.net&gt;
Received: from fontroja.oskuro.net ([78.46.213.114]:51364)
 by buxtehude.debian.org with esmtps
 (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256)
 (Exim 4.96) (envelope-from &lt;jordi@oskuro.net&gt;) id 1xEPzn-003TvS-1V
 for submit@bugs.debian.org; Wed, 07 Oct 2026 11:39:39 +0000
Received: from gallinera.oskuro.net (unknown [85.235.71.99])
 by fontroja.oskuro.net (Postfix) with ESMTPSA id 926E540DE8
 for &lt;submit@bugs.debian.org&gt;; Wed, 07 Oct 2026 13:33:34 +0200 (CEST)
Received: by gallinera.oskuro.net (Postfix, from userid 1000)
 id 63EAD34006D; Wed, 07 Oct 2026 13:33:33 +0200 (CEST)
Date: Wed, 7 Oct 2026 13:33:33 +0200
From: Jordi Mallach &lt;jordi@debian.org&gt;
To: submit@bugs.debian.org
Subject: libgnustep-base1.31: NSRegularExpression returns nil when a
 replacement yields an empty string
Message-ID: &lt;asYuDSVWVyG_kpHl@gallinera.oskuro.net&gt;
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
X-Greylist: delayed 353 seconds by postgrey-1.37 at buxtehude;
 Wed, 07 Oct 2026 11:39:39 UTC
Delivered-To: submit@bugs.debian.org

Package: libgnustep-base1.31
Version: 1.31.1-4+b2
Severity: important
Tags: patch fixed-upstream
Forwarded: https://github.com/gnustep/libs-base/issues/800
Control: affects -1 src:sogo

Dear Maintainer,

-[NSRegularExpression stringByReplacingMatchesInString:options:range:withTemplate:]
returns nil instead of @&quot;&quot; whenever the result of the replacement is
empty, e.g. when the pattern matches the whole input, or the input is
empty. -replaceMatchesInString:options:range:withTemplate: has the same
problem and leaves the mutable string untouched.

Debian builds the non-UText code path, which first asks ICU for the output
length with a zero-sized buffer:

  outLength = uregex_replaceAll(r, replacement, replLength, NULL, 0, &amp;s);
  if (0 == s || U_BUFFER_OVERFLOW_ERROR == s)

For an empty result ICU returns 0 with U_STRING_NOT_TERMINATED_WARNING,
which is a warning (negative), not an error, but the &quot;0 == s&quot; check
treats it as a failure and the method returns nil.

Upstream fixed this in libs-base commit 188b2a3faee4 (&quot;fix for issue
#800&quot;), which replaces the &quot;0 == s&quot; checks with U_SUCCESS(s) throughout
Source/NSRegularExpression.m and adds test cases:

  https://github.com/gnustep/libs-base/commit/188b2a3faee4e88d3371000690d0930e15545f06

The replacement hunks apply to 1.31.1 with small offsets. The two
uregex_lookingAt()/uregex_findNext() hunks need adjusting by hand, as
upstream refactored that code in 09de0f4720fa. Please consider
backporting it.

Thanks,
Jordi
]