-
Task
-
Resolution: Not a Bug
-
Medium
-
None
-
None
If the bookstore JSON is modified to include a book with a square bracket in the title (which is the key in the model), that book cannot be queried. Here is such sample book:
"books" : [ { "title": "Catching Fire: The Hunger Games [Book 2]", "lang": "English", "authors": ["Suzanne Collins"], "pub_year": 2009, "price": 29 } ]
Investigation shows that this data is being written to the database with xpath:
/bookstore/categories[@code='5']/books[@title='Catching Fire: The Hunger Games [Book 2]']
A query such as '//books' will not include this result, nor other queries such as '//books[@title="Catching Fire: The Hunger Games [Book 2]"]'
Note the problem seems to also occur if a non-key attribute contains square brackets:
'//books/authors[text()="Joe Bloggs [translator]"]'
This needs further testing to confirm.
Proposed Solution
When data nodes are being parsed, square brackets could be escaped e.g. /bookstore
/categories[@code='5']/books[@title='Catching Fire: The Hunger Games \[Book 2\]']
The query regex would require modification to support this.