Menu

#2656 (ok 3.0.1) ForceSSL generates incorrect redirections

3.0.0
fixed
1
2013-06-11
2008-03-14
No

When ForceSSL is turned on, a URL like
http://server/phpMyAdmin/
is redirected to
https://server/phpMyAdmin/?collation_connection=utf8_unicode_ci&token=...

This is incorrect: the URL should contain & and not &amp;. The &amp; encoding is only used for embedding the URL into an HTML document. It should never be treated as part of the URL itself. The &amp; should be generated with htmlspecialchars() at the time that a tag like <a href="..."> is generated.

Discussion

  • Marc Delisle

    Marc Delisle - 2008-09-25
    • assigned_to: nobody --> lem9
     
  • Marc Delisle

    Marc Delisle - 2008-09-25

    Suggested patch (for trunk):
    Index: libraries/common.inc.php
    ===================================================================
    --- libraries/common.inc.php (revision 11614)
    +++ libraries/common.inc.php (copie de travail)
    @@ -539,7 +539,7 @@
    PMA_sendHeaderLocation(
    preg_replace('/^http/', 'https',
    $_SESSION['PMA_Config']->get('PmaAbsoluteUri'))
    - . PMA_generate_common_url($_GET));
    + . PMA_generate_common_url($_GET, '', '&'));
    exit;
    }

     
  • Marc Delisle

    Marc Delisle - 2008-09-26

    Fixed in subversion, thanks for reporting.

     
  • Marc Delisle

    Marc Delisle - 2008-09-26
    • summary: ForceSSL generates incorrectly escaped redirections --> (ok 3.0.0-rc3) ForceSSL generates incorrect redirections
    • priority: 5 --> 1
    • status: open --> open-fixed
     
  • Marc Delisle

    Marc Delisle - 2008-09-27
    • status: open-fixed --> closed-fixed
     
  • Glenn

    Glenn - 2008-10-05

    The suggested patch contains an error.

    The line containing the call to PMA_generate_common_url() should be

    . PMA_generate_common_url($_GET, '', '?'));

    to force non-html url generation with '&' separators.

    The third argument becomes ($args[2] in PMA_generate_common_url() and overrides the default value of $questionmark in that function. Passing '&' for the third argument is incorrect in this context, as the query string must begin with '?' not '&'.

     
  • Marc Delisle

    Marc Delisle - 2008-10-06
    • priority: 1 --> 5
    • summary: (ok 3.0.0-rc3) ForceSSL generates incorrect redirections --> ForceSSL generates incorrect redirections
    • status: closed-fixed --> open
     
  • Marc Delisle

    Marc Delisle - 2008-10-06

    The doc for this function was not clear, I'll clarify it. But the correct calling is
    PMA_generate_common_url($_GET, '&');
    because first parameter is an array.

     
  • Marc Delisle

    Marc Delisle - 2008-10-06
    • milestone: 812350 --> 3.0.0
     
  • Marc Delisle

    Marc Delisle - 2008-10-06
    • summary: ForceSSL generates incorrect redirections --> (ok 3.0.1) ForceSSL generates incorrect redirections
    • priority: 5 --> 1
    • status: open --> open-fixed
     
  • Glenn

    Glenn - 2008-10-06

    Well, yes, but not the best practice. The call

    PMA_generate_common_url($_GET, '&');

    will work, but not because the second argument is '&'. Using '&' as the second argument implies it sets '&' as the literal separator character. A better call would be

    PMA_generate_common_url($_GET, '');

    or anything other than 'html' for the second argument. The second argument becomes $args[1] in the function. If present it sets the value for $encode, preventing 'html' from being set by default. If $encode == 'html', the result is passed through htmlspecialchars(). Using '&' as the second argument only works because it is an arbitrary value other than 'html'. However, calling the function that way implies that the second argument forces the literal character '&' as the separator, and that isn't how the function actually works. The function provides no ability to override the separator character through its arguments, only whether or not it is passed through htmlspecialchars().

     
  • Marc Delisle

    Marc Delisle - 2008-10-07

    Thanks for your comments. I think the best call would be this one:

    PMA_generate_common_url($_GET, 'text');

    with a change to the comments for second parameter, agreed?

     
  • Marc Delisle

    Marc Delisle - 2008-10-29
    • status: open-fixed --> closed-fixed
     
  • Michal Čihař

    Michal Čihař - 2013-06-11
    • Status: closed-fixed --> fixed