Moodle
  1. Moodle
  2. MDL-1487

Glossary filter problems when regex chars in concepts

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.3
    • Fix Version/s: None
    • Component/s: Glossary
    • Labels:
      None
    • Environment:
      All
    • Affected Branches:
      MOODLE_13_STABLE
    • Rank:
      10254

      Description

      see description in:

      http://moodle.org/mod/forum/discuss.php?d=7891

      special regex charecters are not quoted correctly in mod/glossary/filter.php function glossary_link_concepts

      maybe following could work:

      instead of line 124:

      $concept = str_replace(/, \/, $concept);

      use:

      $concept = preg_quote($concept, /);

      $concept = str_replace(\/, /, $concept);

      and comment out lines 184-186:

      $list_of_words_cp = str_replace('{', '{', $list_of_words_cp);

      $list_of_words_cp = str_replace('+', '+', $list_of_words_cp);

      $list_of_words_cp = str_replace('(', '(', $list_of_words_cp);

        Activity

        Hide
        Martin Dougiamas added a comment -

        From Petr Skoda (skodak at centrum.cz) Friday, 28 May 2004, 06:38 AM:

        str_replace(
        /, /, $concept);

        the first / is backslashed! I do not know how to type it here

        From Eloy Lafuente (stronk7 at moodle.org) Friday, 28 May 2004, 06:50 AM:

        Hi Petr,

        we was working at the same time in the same issue. Some hours ago I saw Steven post in Moodle forums and I started analysing the code.

        As that part of the glossary wasn't modified prior to 1.3 (because we were running near release date), today I've applied some changes (deep) that I used in activity_names filter.

        Now, I think that this issue will be solved and the code is a bit more clear !!

        I send the modified mod/glossary/filter.php to you as usual...

        After some tests, I'll upload it to CVS.

        Thanks and ciao

        From Petr Skoda (skodak at centrum.cz) Friday, 28 May 2004, 07:04 AM:

        hi!

        I have tested your solution on that specific long sample - everything seems now ok

        I have closed this bug, reopen if necessary.

        There is also an issue with accented national characters -> fullmatch does not work for them, but it needs some broader discussion, because there are many such places in moodle code. IMHO constructs like a-zA-Z should not be used, words should be marked by delimiters (spaces, punctuation marks, line breaks, etc.)

        skodak

        From Eloy Lafuente (stronk7 at moodle.org) Friday, 28 May 2004, 07:24 AM:

        Hi Petr,

        About National Character Support, perhaps we should open a discussion in moodle.org to see possible solutions, implications because I think it's a issue about all Moodle and the solution should be applied globally.

        And a lot of things must be decided: encoding to UTF, wrapper functions, increase php requirements, possible implementations...

        Perhaps now could be a good moment to start talking about this...

        Isn't it?

        From Martin Dougiamas (martin at moodle.com) Friday, 28 May 2004, 09:28 AM:

        Ah! Good to learn about preg_quote ... thanks!

        Show
        Martin Dougiamas added a comment - From Petr Skoda (skodak at centrum.cz) Friday, 28 May 2004, 06:38 AM: str_replace( /, /, $concept); the first / is backslashed! I do not know how to type it here From Eloy Lafuente (stronk7 at moodle.org) Friday, 28 May 2004, 06:50 AM: Hi Petr, we was working at the same time in the same issue. Some hours ago I saw Steven post in Moodle forums and I started analysing the code. As that part of the glossary wasn't modified prior to 1.3 (because we were running near release date), today I've applied some changes (deep) that I used in activity_names filter. Now, I think that this issue will be solved and the code is a bit more clear !! I send the modified mod/glossary/filter.php to you as usual... After some tests, I'll upload it to CVS. Thanks and ciao From Petr Skoda (skodak at centrum.cz) Friday, 28 May 2004, 07:04 AM: hi! I have tested your solution on that specific long sample - everything seems now ok I have closed this bug, reopen if necessary. There is also an issue with accented national characters -> fullmatch does not work for them, but it needs some broader discussion, because there are many such places in moodle code. IMHO constructs like a-zA-Z should not be used, words should be marked by delimiters (spaces, punctuation marks, line breaks, etc.) skodak From Eloy Lafuente (stronk7 at moodle.org) Friday, 28 May 2004, 07:24 AM: Hi Petr, About National Character Support, perhaps we should open a discussion in moodle.org to see possible solutions, implications because I think it's a issue about all Moodle and the solution should be applied globally. And a lot of things must be decided: encoding to UTF, wrapper functions, increase php requirements, possible implementations... Perhaps now could be a good moment to start talking about this... Isn't it? From Martin Dougiamas (martin at moodle.com) Friday, 28 May 2004, 09:28 AM: Ah! Good to learn about preg_quote ... thanks!
        Hide
        Michael Blake added a comment -

        assign to a valid user

        Show
        Michael Blake added a comment - assign to a valid user

          People

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

            Dates

            • Created:
              Updated:
              Resolved: