does PHP automatically run rawurldecode on any any URL to figure out what pass parameters to capture?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lawrence k

    #1

    does PHP automatically run rawurldecode on any any URL to figure out what pass parameters to capture?

    I noticed, to my surprise, that PHP was still able to figure that
    "search" is suppose to be an array:

    http://www.accumulist.com/index.php?...ds%5D=bluewall

    I'm impressed with that. Till now I've used POST in my forms as the
    method for doing search forms, but now I'm trying GET and everything is
    working fine.

    Do most browsers auto encode a form input when it is sent via a GET
    method? Is the encoding standard? It does not break anywhere?

    What is PHP doing that it is able to figure out that in the above URL
    "search" should be an array variable in the $_GET array?

  • Iván Sánchez Ortega

    #2
    Re: does PHP automatically run rawurldecode on any any URL to figure out what pass parameters to capture?

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    lawrence k wrote:
    [color=blue]
    > Do most browsers auto encode a form input when it is sent via a GET
    > method? Is the encoding standard? It does not break anywhere?[/color]

    Yes, most browsers do encode form data prior to submitting it. Yes, it is a
    standard, as per RFC1738. No, it doesn't usually break.

    However, you should be careful about echo()ing URLs with spaces or other
    simbols in them, for example:

    <?php
    $escaped_term = rawurlencode($t erm);
    echo "<a href='search.ph p?term=$escaped _term'>Repeat search</a>";
    ?>

    In most other cases, you won't need to worry about URL encoding.

    - --
    - ----------------------------------
    Iván Sánchez Ortega -i-punto-sanchez--arroba-mirame-punto-net

    Un ordenador no es un televisor ni un microondas, es una herramienta
    compleja.
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.2 (GNU/Linux)

    iD8DBQFDv6HB3jc Q2mg3Pc8RAhGRAJ 0baLUwxzItmsycP RgaX6eaOFqWTQCe Iv0J
    T/DIPOPuOpRLmDB2v 4F+f0g=
    =w86i
    -----END PGP SIGNATURE-----

    Comment

    • Jonathan

      #3
      Re: does PHP automatically run rawurldecode on any any URL to figureout what pass parameters to capture?

      lawrence k wrote:[color=blue]
      > I noticed, to my surprise, that PHP was still able to figure that
      > "search" is suppose to be an array:
      >
      > http://www.accumulist.com/index.php?...ds%5D=bluewall
      >
      > I'm impressed with that. Till now I've used POST in my forms as the
      > method for doing search forms, but now I'm trying GET and everything is
      > working fine.[/color]

      There might be a drawback if your get statements tend to get very long
      (2k charachters):


      Comment

      • lawrence k

        #4
        Re: does PHP automatically run rawurldecode on any any URL to figure out what pass parameters to capture?


        Iván Sánchez Ortega wrote:[color=blue]
        > However, you should be careful about echo()ing URLs with spaces or other
        > simbols in them, for example:
        >
        > <?php
        > $escaped_term = rawurlencode($t erm);
        > echo "<a href='search.ph p?term=$escaped _term'>Repeat search</a>";
        > ?>
        >
        > In most other cases, you won't need to worry about URL encoding.[/color]

        I think you mean, if I understand you right, that I need to use
        rawurlencode if I'm going to use a url in an echo statement, but most
        of the rest of the time, away from echo statements, I do not have to
        sweat much about rawurlencoding, because browsers do so much encoding
        automatically?

        Comment

        Working...