Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-14816

Escape special regex characters before applying perl compatible regex substitution of field names for database activity's advanced search

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9, 1.9.1
    • Fix Version/s: 1.9.2
    • Labels:
      None
    • Database:
      Any
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE

      Description

      When the name of a field contains a special perl-compatible regex character such as "/" or "+", the advanced search page will not create an input box for such fields. In the attached screenshot this is shown for the field with the name "A/X". The same field type (text) with the name "AX" works fine, but "A/X" or "A + X" does not work.

        Gliffy Diagrams

        1. MDL-14816_20080518.patch
          0.9 kB
          Robert Allerstorfer
        1. No_search_input_box.png
          13 kB

          Activity

          roal Robert Allerstorfer created issue -
          Hide
          roal Robert Allerstorfer added a comment -

          The attached patch fixes this bug.

          The solution was to escape the chars / and + with \ before applying the perl regex substitution.

          Show
          roal Robert Allerstorfer added a comment - The attached patch fixes this bug. The solution was to escape the chars / and + with \ before applying the perl regex substitution.
          roal Robert Allerstorfer made changes -
          Field Original Value New Value
          Attachment MDL-14816.patch [ 13967 ]
          Hide
          stronk7 Eloy Lafuente (stronk7) added a comment -

          Hi Robert,

          shouldn't be preg_quote() instead of addcslashes? That's the natural function to escape characters with "meaning" in regular expressions AFAIK.

          Ciao

          Show
          stronk7 Eloy Lafuente (stronk7) added a comment - Hi Robert, shouldn't be preg_quote() instead of addcslashes? That's the natural function to escape characters with "meaning" in regular expressions AFAIK. Ciao
          Hide
          stronk7 Eloy Lafuente (stronk7) added a comment -

          Also,

          feel free to assign yourself database bugs (I think that if you add me or Petr or Martin for confirmation/vote is a good strategy). Ususally one +1 is required to go to HEAD and +2 for stable versions.

          Thanks and ciao

          Show
          stronk7 Eloy Lafuente (stronk7) added a comment - Also, feel free to assign yourself database bugs (I think that if you add me or Petr or Martin for confirmation/vote is a good strategy). Ususally one +1 is required to go to HEAD and +2 for stable versions. Thanks and ciao
          Hide
          roal Robert Allerstorfer added a comment -

          Hi Eloy,

          yes, preg_quote() is the better solution. Then I think we should use
          $fieldname = preg_quote($fieldname, '/');

          And thanks for explaing the usual committing policy

          Show
          roal Robert Allerstorfer added a comment - Hi Eloy, yes, preg_quote() is the better solution. Then I think we should use $fieldname = preg_quote($fieldname, '/'); And thanks for explaing the usual committing policy
          Hide
          roal Robert Allerstorfer added a comment -

          OK, here is the new patch (MDL-14816_20080518.patch) using preg_quote($fieldname, '/'). It works fine - I have tested it successfully.

          Show
          roal Robert Allerstorfer added a comment - OK, here is the new patch ( MDL-14816 _20080518.patch) using preg_quote($fieldname, '/'). It works fine - I have tested it successfully.
          roal Robert Allerstorfer made changes -
          Attachment MDL-14816_20080518.patch [ 14025 ]
          roal Robert Allerstorfer made changes -
          Attachment MDL-14816.patch [ 13967 ]
          roal Robert Allerstorfer made changes -
          Assignee Eloy Lafuente (stronk7) [ stronk7 ] Robert Allerstorfer [ roal ]
          Hide
          roal Robert Allerstorfer added a comment -

          Eloy,

          as you suggested, I have re-assigned this issue to me. The solution is clear, so I'm planning to commit my patch soon unless there is feedback against it.

          Thanks for your attention.

          Show
          roal Robert Allerstorfer added a comment - Eloy, as you suggested, I have re-assigned this issue to me. The solution is clear, so I'm planning to commit my patch soon unless there is feedback against it. Thanks for your attention.
          roal Robert Allerstorfer made changes -
          Fix Version/s 1.9.2 [ 10280 ]
          Affects Version/s 1.9.1 [ 10240 ]
          roal Robert Allerstorfer made changes -
          Summary Advanced search does not create input box for fields containing an arithmetical operator Escape special regex characters before applying perl compatible regex substitution of field names for database activity's advanced search
          Description When the name of a field contains an arithmetical operator such as "/" or "+", the advanced search page will not create an input box for such fields. In the attached screenshot this is shown for the field with the name "A/X". The same field type (text) with the name "AX" works fine, but "A/X" or "A + X" does not work. When the name of a field contains a special perl-compatible regex character such as "/" or "+", the advanced search page will not create an input box for such fields. In the attached screenshot this is shown for the field with the name "A/X". The same field type (text) with the name "AX" works fine, but "A/X" or "A + X" does not work.
          roal Robert Allerstorfer made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Hide
          dongsheng Dongsheng Cai added a comment -

          Verified, thanks, Robert.

          Show
          dongsheng Dongsheng Cai added a comment - Verified, thanks, Robert.
          dongsheng Dongsheng Cai made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          dongsheng Dongsheng Cai made changes -
          QA Assignee dongsheng
          dougiamas Martin Dougiamas made changes -
          Workflow jira [ 26422 ] MDL Workflow [ 59766 ]
          dougiamas Martin Dougiamas made changes -
          Workflow MDL Workflow [ 59766 ] MDL Full Workflow [ 88922 ]
          Subversion JIRA

          Links Hierarchy

           Documentation

          Invalid license: EXPIRED

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                11/Jul/08