Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-13199

regex uses too strict index bounds when | is after a metacharacter

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: 2.4.9, 2.6.0-rc1
    • Fix Version/s: None
    • Component/s: Querying
    • Labels:
      None
    • Operating System:
      ALL

      Description

      This occurs in 2.4.9 and 2.6.0-rc1.

      > db.a.insert({a: "foo"})
      > db.a.find({a: /^abc+|foo/})
      { "_id" : ObjectId("53228d743704a19f9cb03ea6"), "a" : "foo" }
      > db.a.ensureIndex({a: 1})
      > db.a.find({a: /^abc+|foo/})

      The problem is that simpleRegex returns success when it hits most metacharacters, and doesn't continue on to find the |.

      I suggest that you check the entire regex first for | and immediately bail out with an empty string if it's find. (This is not 100% optimal because the | could have been escaped, but it's certainly correct.)

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              david.storch David Storch
              Reporter:
              glasser David Glasser
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: