Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No QR code appearing in settings #17567

Open
netfiesta opened this issue May 30, 2022 · 10 comments
Open

No QR code appearing in settings #17567

netfiesta opened this issue May 30, 2022 · 10 comments
Labels
Bug A problem or regression with an existing feature waiting on upstream Issues blocked by a third-party
Projects

Comments

@netfiesta
Copy link

netfiesta commented May 30, 2022

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.

@williamdes
Copy link
Member

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 williamdes added the question Used when we need feedback from the submitter or when the issue is a question about PMA label May 30, 2022
@williamdes williamdes added this to Needs triage in Questions via automation May 30, 2022
@williamdes williamdes moved this from Needs triage to Needs a second check to be a bug in Questions May 30, 2022
@netfiesta
Copy link
Author

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? ;-)

@williamdes
Copy link
Member

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 ?

@netfiesta
Copy link
Author

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?

@williamdes
Copy link
Member

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 williamdes added Bug A problem or regression with an existing feature waiting on upstream Issues blocked by a third-party and removed question Used when we need feedback from the submitter or when the issue is a question about PMA labels May 30, 2022
@williamdes williamdes removed this from Needs a second check to be a bug in Questions May 30, 2022
@williamdes williamdes added this to Needs triage in issues via automation May 30, 2022
@liviuconcioiu
Copy link
Contributor

liviuconcioiu commented May 31, 2022

Decimal point is different. I've also found another issue like this on Github PHPOffice/PHPWord#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
        )

)

@netfiesta
Copy link
Author

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

@williamdes
Copy link
Member

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

@netfiesta
Copy link
Author

netfiesta commented May 31, 2022

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! :-)

@DASPRiD
Copy link

DASPRiD commented Apr 18, 2024

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

Bacon/BaconQrCode#177

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A problem or regression with an existing feature waiting on upstream Issues blocked by a third-party
Projects
issues
  
Needs triage
Development

No branches or pull requests

4 participants