DiffusionRequest regex error


#1

Observed Behavior:
Visiting some pages in my installation result in errors being logged:

[2018-11-01 18:16:13] ERROR 2: preg_match(): Compilation failed: invalid range in character class at offset 32 at [<phabricator>/src/applications/diffusion/request/DiffusionRequest.php:493]
arcanist(head=stable, ref.master=2650e8627a20, ref.stable=f5e65a808e21), phabricator(head=stable, ref.master=bc6c8c0e93a7, ref.stable=a0f323a72f81), phutil(head=master, ref.master=603209bb1756)
  #0 preg_match(string, string, array) called at [<phabricator>/src/applications/diffusion/request/DiffusionRequest.php:493]
  #1 DiffusionRequest::parseRequestBlob(string, boolean) called at [<phabricator>/src/applications/diffusion/request/DiffusionRequest.php:208]
  #2 DiffusionRequest::initializeFromDictionary(array) called at [<phabricator>/src/applications/diffusion/request/DiffusionRequest.php:115]
  #3 DiffusionRequest::newFromDictionary(array) called at [<phabricator>/src/applications/diffusion/controller/DiffusionController.php:62]
  #4 DiffusionController::loadContext(array) called at [<phabricator>/src/applications/diffusion/controller/DiffusionController.php:41]
  #5 DiffusionController::loadDiffusionContext() called at [<phabricator>/src/applications/diffusion/controller/DiffusionDiffController.php:14]
  #6 DiffusionDiffController::handleRequest(AphrontRequest) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:258]
  #7 AphrontApplicationConfiguration::processRequest(AphrontRequest, PhutilDeferredLog, AphrontPHPHTTPSink, MultimeterControl) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:178]
  #8 AphrontApplicationConfiguration::runHTTPRequest(AphrontPHPHTTPSink) called at [<phabricator>/webroot/index.php:17]

Expected Behavior:
No errors logged

Phabricator Version:
phabricator
a0f323a72f8152b65a125e0f84f25c8f92056274 (Wed, Oct 17) (branched from 0a51bc4f05bf5704e3608a839cc199fe69e88834 on origin)
arcanist
f5e65a808e21710fb3818842d5e0b52a0f67c387 (Sep 15 2018) (branched from 2650e8627a20e1bfe334a4a2b787f44ef5d6ebc5 on origin)
phutil
603209bb1756ef9ad3409aaca96d8e6ade72a937 (Mon, Oct 8)
diff
3.5 at /usr/bin/diff
git
2.11.0 at /usr/bin/git
php
PHP 7.3.0RC2 (cli) (built: Oct 4 2018 14:25:15) ( NTS )


#2

Which version of PHP and PCRE are you using (php --version and php -i | grep -i PCRE)?

This particular line/regexp is unchanged since July 2012, so it’s probably something strange in your machine.


#3

I can’t immediately reproduce the error, but the character range specification is incorrect. This:

[\d-,]

…should be:

[\d,-]

…so that the - is interpreted as “literal hyphen” instead of “character range marker”.


#4

https://secure.phabricator.com/D19770 transposes the - and , and should fix this, although I can’t actually reproduce the original error so I’m not entirely sure.


#5
$ php -i | grep -i pcre
PCRE (Perl Compatible Regular Expressions) Support => enabled
PCRE Library Version => 10.31 2018-02-12
PCRE Unicode Version => 10.0.0
$ php --version
PHP 7.3.0RC2 (cli) (built: Oct  4 2018 14:25:15) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.0RC2, Copyright (c) 1999-2018, by Zend Technologies

But the solution I came up with before posting was the same as @epriestley’s.