phpmyadmin icon indicating copy to clipboard operation
phpmyadmin copied to clipboard

No QR code appearing in settings

Open netfiesta opened this issue 3 years ago • 10 comments

I've upgraded from phpMyAdmin 5.0.2 to 5.2.0. Everything seems fine however after the upgrade the QR code to enable 2FA does not show up anymore. It shows a complete white block. I did a inspect on the generated HTML code and notices this issue:

<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="200" height="200" viewBox="0 0 200 200">
<rect x="0" y="0" width="200" height="200" fill="#fefefe"></rect>
<g transform="scale(3,509)">
<g transform="translate(4,4)"><path fill-rule="evenodd" d="[LONG QR CODE]" fill="#000000"></path></g></g></svg>

This <g transform="scale(3,509)"> seems to be incorrect. If I change the comma here to a dot, so 3.509 the QR shows fine. I now made a workaround to fix this but of course it's a workaround...

I've added the following CSS to \templates\preferences\two_factor\configure.twig:

<style>
/* Added because QR would not appear because of scale(3,509) value instead of 3.509 (dot instead of comma). */
svg > g {scale: 3.5;}
</style>

I've also updated the Google2FA and Google2FA-QR libraries to it's latest versions which seems to be working fine.

netfiesta avatar May 30 '22 00:05 netfiesta

Hi @netfiesta Could you share the server specific informations ? What processor architecture do you have ?

Here is the source: https://github.com/Bacon/BaconQrCode/blob/d70c840f68657ce49094b8d91f9ee0cc07fbf66c/src/Renderer/Image/SvgImageBackEnd.php#L100

Could you debug what the input values are ?

williamdes avatar May 30 '22 15:05 williamdes

Hi @netfiesta Could you share the server specific informations ? What processor architecture do you have ?

Here is the source: https://github.com/Bacon/BaconQrCode/blob/d70c840f68657ce49094b8d91f9ee0cc07fbf66c/src/Renderer/Image/SvgImageBackEnd.php#L100

Could you debug what the input values are ?

Hello @williamdes,

Thansk for your quick reply. Sure, my environment is a Windows Server 2019 with PHP 7.4.29 x64 NTS and MySQL 8.0.2. Hmmm, i'm not really a PHP guru, however I have skills in HTML, CSS, JS and C# (.NET) so no clue how I can debug these input values, but maybe you can help me a little with that? ;-)

netfiesta avatar May 30 '22 15:05 netfiesta

Hi @netfiesta Could you share the server specific informations ? What processor architecture do you have ? Here is the source: https://github.com/Bacon/BaconQrCode/blob/d70c840f68657ce49094b8d91f9ee0cc07fbf66c/src/Renderer/Image/SvgImageBackEnd.php#L100 Could you debug what the input values are ?

Hello @williamdes,

Thansk for your quick reply. Sure, my environment is a Windows Server 2019 with PHP 7.4.29 x64 NTS and MySQL 8.0.2. Hmmm, i'm not really a PHP guru, however I have skills in HTML, CSS, JS and C# (.NET) so no clue how I can debug these input values, but maybe you can help me a little with that? ;-)

;)

Could you add this lines in the file just after the line (100) I sent you: phpMyAdminFolder/vendor/bacon/bacon-qr-code/src/Renderer/Image/SvgImageBackEnd.php

        $this->xmlWriter->writeAttribute(
            'transform-raw',
            sprintf('(%s, %s)', $size, self::PRECISION)
        );

And then go back to the QR code page and send the HTML of the <svg zone ?

williamdes avatar May 30 '22 15:05 williamdes

Hi again @williamdes,

Sure, I just did, this is the output:

<g transform="scale(3,509)" transform-raw="(3,5087719298246, 3)">
<g transform="translate(4,4)">
<path fill-rule="evenodd" d="[[i removed the QR, assueme that thats OK??]]" fill="#000000"></path>
</g>
</g>

Is this what you need?

netfiesta avatar May 30 '22 15:05 netfiesta

Hi again @williamdes,

Sure, I just did, this is the output:

<g transform="scale(3,509)" transform-raw="(3,5087719298246, 3)">
<g transform="translate(4,4)">
<path fill-rule="evenodd" d="[[i removed the QR, assueme that thats OK??]]" fill="#000000"></path>
</g>
</g>

Is this what you need?

Perfect ! This strange, the xml writer maybe uses some system specific setting to format floats

I did narrow down this to test.php

<?php

setlocale(LC_ALL, 'fr');

$writer = new XMLWriter();
$writer->openURI('php://output');
$writer->startDocument('1.0','UTF-8');
$writer->setIndent(TRUE);
$size = 3.5087719298246;
$writer->startElement('g');
$writer->writeAttribute(
            'transform',
            sprintf('scale(%s)', round($size, 3))
        );
php -f test.php

On my workstation it does output <g transform="scale(3.509)"

cc @DASPRiD (the author of the lib)

williamdes avatar May 30 '22 16:05 williamdes

Decimal point is different. I've also found another issue like this on Github https://github.com/PHPOffice/PHPWord/issues/1268.

<?php

setlocale(LC_ALL, 'fr_FR');
print_r(localeconv());

setlocale(LC_ALL, 'fr');
print_r(localeconv());
Array
(
    [decimal_point] => .
    [thousands_sep] => 
    [int_curr_symbol] => 
    [currency_symbol] => 
    [mon_decimal_point] => 
    [mon_thousands_sep] => 
    [positive_sign] => 
    [negative_sign] => 
    [int_frac_digits] => 127
    [frac_digits] => 127
    [p_cs_precedes] => 127
    [p_sep_by_space] => 127
    [n_cs_precedes] => 127
    [n_sep_by_space] => 127
    [p_sign_posn] => 127
    [n_sign_posn] => 127
    [grouping] => Array
        (
        )

    [mon_grouping] => Array
        (
        )

)
Array
(
    [decimal_point] => ,
    [thousands_sep] => �
    [int_curr_symbol] => EUR
    [currency_symbol] => �
    [mon_decimal_point] => ,
    [mon_thousands_sep] => �
    [positive_sign] => 
    [negative_sign] => -
    [int_frac_digits] => 2
    [frac_digits] => 2
    [p_cs_precedes] => 0
    [p_sep_by_space] => 1
    [n_cs_precedes] => 0
    [n_sep_by_space] => 1
    [p_sign_posn] => 1
    [n_sign_posn] => 1
    [grouping] => Array
        (
            [0] => 3
        )

    [mon_grouping] => Array
        (
            [0] => 3
        )

)

liviuconcioiu avatar May 31 '22 08:05 liviuconcioiu

Ok, can I do anything more to help here...?

netfiesta avatar May 31 '22 10:05 netfiesta

Ok, can I do anything more to help here...?

Thank you for your help, no for now it's okay I will try do make a fix

williamdes avatar May 31 '22 11:05 williamdes

Ok, can I do anything more to help here...?

Thank you for your help, no for now it's okay I will try do make a fix

OK, that's great! For now I fixed it with the CSS workaround I made, at least it shows the QR again, but a definate solution would be great! Thanks again for the quick reply! :-)

netfiesta avatar May 31 '22 14:05 netfiesta

FYI, there is a pull request to address this (for BaconQrCode v3), waiting for the author to address some outstanding issues:

https://github.com/Bacon/BaconQrCode/pull/177

DASPRiD avatar Apr 18 '24 11:04 DASPRiD