Bug #80961 [Opn->Nab]: PCRE treats ellipsis character as a letter

From: Date: Fri, 16 Apr 2021 09:28:52 +0000
Subject: Bug #80961 [Opn->Nab]: PCRE treats ellipsis character as a letter
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233466@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80961&edit=1

 ID:                 80961
 Updated by:         nikic@php.net
 Reported by:        f dot sowade at r9e dot de
 Summary:            PCRE treats ellipsis character as a letter
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            PCRE related
 Operating System:   Linux and Mac OS X
 PHP Version:        8.0.3
 Block user comment: N
 Private report:     N

 New Comment:

You are missing the /u modifier and seem to have confused \p{P} with \p{Z}. The correct code is:

var_dump(preg_match('/\\p{P}/u', "\u{2026}")); // 1
var_dump(preg_match('/\\p{L}/u', "\u{2026}")); // 0


Previous Comments:
------------------------------------------------------------------------
[2021-04-16 09:19:32] f dot sowade at r9e dot de

Sorry - the Test script should have had a P instead of a Z:

var_dump(IntlChar::ispunct("\u{2026}")); // true
var_dump(IntlChar::isalpha("\u{2026}")); // false

var_dump(preg_match('/\\p{P}/', "\u{2026}")); // 0 (but would expect 1)
var_dump(preg_match('/\\p{L}/', "\u{2026}")); // 1 (but would expect 0)

------------------------------------------------------------------------
[2021-04-16 09:14:18] f dot sowade at r9e dot de

Description:
------------
The intl extension reports the Unicode ellipsis character (U+2026) to be a punctuation. PCRE matches
the ellipsis when matching letters but not when matching punctuation. So the character class for the
ellipsis differs between the intl extension and PCRE. I think that intl is correct here and the
character class should be punctuation. But both extensions should at least agree on the same
character class.

Test script:
---------------
var_dump(IntlChar::ispunct("\u{2026}")); // true
var_dump(IntlChar::isalpha("\u{2026}")); // false

var_dump(preg_match('/\\p{Z}/', "\u{2026}")); // 0 (but would expect 1)
var_dump(preg_match('/\\p{L}/', "\u{2026}")); // 1 (but would expect 0)

Expected result:
----------------
bool(true)
bool(false)
int(1)
int(0)

Actual result:
--------------
bool(true)
bool(false)
int(0)
int(1)


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=80961&edit=1


Thread (3 messages)

« previous php.bugs (#233466) next »