php-remote-storage icon indicating copy to clipboard operation
php-remote-storage copied to clipboard

FastCGI sent in stderr:

Open bytersproblem opened this issue 4 years ago • 1 comments

With the newest release (1.0.5) and nginx as set up in the issue #44 Everything works except for the sync part. I use encryptic notes.

FastCGI sent in stderr: "PHP message: PHP Warning:  preg_match(): Compilation failed: invalid range in character class at offset 20 in /var/www/php-remote-storage/vendor/fkooman/rest-plugin-authentication-bearer/src/fkooman/Rest/Plugin/Authentication/Bearer/BearerAuthentication.php on line 141" while reading response header from upstream,

bytersproblem avatar Sep 26 '21 03:09 bytersproblem

You can modify the file vendor/fkooman/rest-plugin-authentication-bearer/src/fkooman/Rest/Plugin/Authentication/Bearer/BearerAuthentication.php that currently contains this:

    public static function validateTokenSyntax($bearerToken)
    {
        // b64token = 1*( ALPHA / DIGIT / "-" / "." / "_" / "~" / "+" / "/" ) *"="
        if (1 !== preg_match('|^[[:alpha:][:digit:]-._~+/]+=*$|', $bearerToken)) {
            throw new BadRequestException(
                'invalid_request',
                'invalid token syntax'
            );
        }
    }

to:

    public static function validateTokenSyntax($bearerToken)
    {
        // b64token = 1*( ALPHA / DIGIT / "-" / "." / "_" / "~" / "+" / "/" ) *"="
        if (1 !== preg_match('|^[[:alpha:][:digit:]\-._~+/]+=*$|', $bearerToken)) {
            throw new BadRequestException(
                'invalid_request',
                'invalid token syntax'
            );
        }
    }

i.e.: escape the - character: \-.

It seems the current code breaks in PHP >= 7.3 due to some changes in the regexp engine in PHP.

fkooman avatar Sep 27 '21 07:09 fkooman