Moodle
  1. Moodle
  2. MDL-29700

moodle_url converts get params with '.' to an underscore

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0.3, 2.4.4, 2.5
    • Fix Version/s: BACKEND
    • Component/s: Libraries
    • Labels:
    • Environment:
      Windows 7, Internet Explorer and Google Chrome
    • Testing Instructions:
      Hide

      Add this unit test and make it pass:

      diff --git a/lib/tests/weblib_test.php b/lib/tests/weblib_test.php
      index 8ba4a4d..7d9254e 100644
      --- a/lib/tests/weblib_test.php
      +++ b/lib/tests/weblib_test.php
      @@ -292,6 +292,12 @@ class web_testcase extends advanced_testcase {
               $url4->out_as_local_url();
           }
       
      +    public function test_fullstop_in_url() {
      +        $originalurl = 'http://moodle.org/?a.dot=1';
      +        $url = new moodle_url($originalurl);
      +        $this->assertSame($url->out(false), $originalurl);
      +    }
      +
           public function test_clean_text() {
               $text = "lala <applet>xx</applet>";
               $this->assertEquals($text, clean_text($text, FORMAT_PLAIN));
      

      Show
      Add this unit test and make it pass: diff --git a/lib/tests/weblib_test.php b/lib/tests/weblib_test.php index 8ba4a4d..7d9254e 100644 --- a/lib/tests/weblib_test.php +++ b/lib/tests/weblib_test.php @@ -292,6 +292,12 @@ class web_testcase extends advanced_testcase { $url4->out_as_local_url(); }   + public function test_fullstop_in_url() { + $originalurl = 'http://moodle.org/?a.dot=1'; + $url = new moodle_url($originalurl); + $this->assertSame($url->out(false), $originalurl); + } + public function test_clean_text() { $text = "lala <applet>xx</applet>"; $this->assertEquals($text, clean_text($text, FORMAT_PLAIN));
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE

      Description

      When the following RSS feed:

      http://www.solarindustrymag.com/rss/rss.xml

      is added to the Remote RSS block, the links displayed have been modified from the correct link as follows:

      The link in the RSS feed, and the link for each story reads (for example) as:

      http://www.solarindustrymag.com/e107_plugins/content/content.php?content.8868

      But when it is linked in the RSS block, the link is:

      http://www.solarindustrymag.com/e107_plugins/content/content.php?content_8868=

      The last period has been changed to an underscore and an equal sign has been added. The link no longer directs the user to the correct story.

      Three points:

      1.) The RSS feed linked above works using other RSS aggregators (Google Reader, for instance).
      2.) The links and link descriptions are displaying properly (the article title is correct, it's just the link that is broken)
      3.) I tried a few other RSS feeds and they all seem to work fine (Washington Post, CNN, etc)

      In conclusion, I do not KNOW that this is a problem in Moodle, as opposed to a problem with the feed, but if you look at the feed itself the links are listed correctly.

        Gliffy Diagrams

        1. test.php
          0.4 kB
          Dan Poltawski

          Issue Links

            Activity

            Hide
            Dan Poltawski added a comment -

            This appears to be caused by moodle_url messing with the params. I've come up with a simple test file which demonstrates the problem.

            Show
            Dan Poltawski added a comment - This appears to be caused by moodle_url messing with the params. I've come up with a simple test file which demonstrates the problem.
            Hide
            Dan Poltawski added a comment -

            urgh, turns out this comes from the php function parse_str:

            http://php.net/manual/en/function.parse-str.php

            From the comments:

            <?php
            $query = 'foo.bar=stuff';    // foo (dot) bar
            parse_str( $query , $output);
            print_r( $output );
            ?>
             
            will output (underscore)
             
            Array
            (
                [foo_bar] => stuff
            )
            

            Show
            Dan Poltawski added a comment - urgh, turns out this comes from the php function parse_str: http://php.net/manual/en/function.parse-str.php From the comments: <?php $query = 'foo.bar=stuff'; // foo (dot) bar parse_str( $query , $output); print_r( $output ); ?>   will output (underscore)   Array ( [foo_bar] => stuff )
            Hide
            Dan Poltawski added a comment -

            As far as I can tell, a . in the get parameter is perfectly valid by the RFC's, so there is no reason for php's parse_str to mess it up. However, I don't have any clever ideas to work around this issue.

            I will not be able to work on this issue in the immediate future. In order to create a truer sense of the state of this issue and to allow other developers to have chance to become involved, I am removing myself as the assignee of this issue.
            For more information, see http://docs.moodle.org/dev/Changes_to_issue_assignment

            Show
            Dan Poltawski added a comment - As far as I can tell, a . in the get parameter is perfectly valid by the RFC's, so there is no reason for php's parse_str to mess it up. However, I don't have any clever ideas to work around this issue. I will not be able to work on this issue in the immediate future. In order to create a truer sense of the state of this issue and to allow other developers to have chance to become involved, I am removing myself as the assignee of this issue. For more information, see http://docs.moodle.org/dev/Changes_to_issue_assignment
            Hide
            Dan Poltawski added a comment -

            (Note for anyone who picks this up - I have put the unit test demonstrating the problem in the teting instructions field!)

            Show
            Dan Poltawski added a comment - (Note for anyone who picks this up - I have put the unit test demonstrating the problem in the teting instructions field!)
            Hide
            Petr Skoda added a comment -

            I am afraid moodle_url works for moodle urls only, it is not designed to work with general urls - see for more problems MDL-33188

            Show
            Petr Skoda added a comment - I am afraid moodle_url works for moodle urls only, it is not designed to work with general urls - see for more problems MDL-33188
            Hide
            Mohamed Alsharaf added a comment -

            This issue submitted in php bug tracker since 2011: https://bugs.php.net/bug.php?id=55102

            Show
            Mohamed Alsharaf added a comment - This issue submitted in php bug tracker since 2011: https://bugs.php.net/bug.php?id=55102

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated: