🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.debian.bugs.dist
Article #33

Bug#1150228: libgnustep-base1.31: NSRegularExpression returns nil when a replacement yields an empty string

#33
From: Jordi Mallach
Date: Wed, 07 Oct 2026 11:50
38 lines
3227 bytes
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 @"" 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, &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 "0 == s" check
treats it as a failure and the method returns nil.

Upstream fixed this in libs-base commit 188b2a3faee4 ("fix for issue
#800"), which replaces the "0 == s" 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
Technical Details
Message-ID: <NLyjL-44pW-9@gated-at.bofh.it>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!2.eu.feeder.erje.net!3.eu.feeder.erje.net!feeder.erje.net!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomod

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!2.eu.feeder.erje.net!3.eu.feeder.erje.net!feeder.erje.net!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomod
From: Jordi Mallach <jordi@debian.org>
Newsgroups: linux.debian.bugs.dist
Subject: Bug#1150228: libgnustep-base1.31: NSRegularExpression returns nil when a replacement yields an empty string
Date: Wed, 07 Oct 2026 13:50:01 +0200
Message-ID: <NLyjL-44pW-9@gated-at.bofh.it>
X-Mailbox-Line: From debian-bugs-dist-request@lists.debian.org  Wed Oct  7 11:41:09 2026
Old-Return-Path: <debbugs@buxtehude.debian.org>
X-Spam-Flag: NO
X-Spam-Score: -1.9
Reply-To: Jordi Mallach <jordi@debian.org>, 1150228@bugs.debian.org
Resent-To: debian-bugs-dist@lists.debian.org
Resent-Cc: pkg-gnustep-maintainers@lists.alioth.debian.org
X-Debian-Pr-Message: report 1150228
X-Debian-Pr-Package: libgnustep-base1.31
X-Debian-Pr-Keywords: fixed-upstream patch
X-Debian-Pr-Source: gnustep-base
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
X-Debian-Message: from BTS
X-Mailing-List: <debian-bugs-dist@lists.debian.org> archive/latest/1995525
List-ID: <debian-bugs-dist.lists.debian.org>
List-URL: <https://lists.debian.org/debian-bugs-dist/>
Approved: robomod@news.nic.it
Lines: 38
Organization: linux.* mail to news gateway
Sender: robomod@news.nic.it
X-Original-Date: Wed, 7 Oct 2026 13:33:33 +0200
X-Original-Message-ID: <asYuDSVWVyG_kpHl@gallinera.oskuro.net>