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

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

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.4.9, 2.6.0-rc1
    • Component/s: Querying
    • Labels:
      None
    • ALL

      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.)

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

              Created:
              Updated:
              Resolved: