Skip to content

Commit 097ce0d

Browse files
committed
Fix: Doesn't recognize multiple escaped characters.
1 parent 83806f5 commit 097ce0d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/main/java/kiss/Element.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ public class Element implements Iterable<Element> {
4646
* Original pattern.
4747
*
4848
* <pre>
49-
* ([>~+\-, ]*)?((?:(?:\w+|\*)\|)?(?:\w+(?:\\.\w+)?|\*))?(?:#(\w+))?((?:\.\w+)*)(?:\[\s?([\w:]+)(?:\s*([=~^$*|])?=\s*["]([^"]*)["])?\s?\])?(?::([\w-]+)(?:\((odd|even|(\d*)(n)?(?:\+(\d+))?|(?:.*))\))?)?
49+
* ([>~+\-, ]*)?((?:(?:\w+|\*)\|)?(?:\w+(?:\\.\w+)*|\*))?(?:#(\w+))?((?:\.\w+)*)(?:\[\s?([\w:]+)(?:\s*([=~^$*|])?=\s*["]([^"]*)["])?\s?\])?(?::([\w-]+)(?:\((odd|even|(\d*)(n)?(?:\+(\d+))?|(?:.*))\))?)?
5050
* </pre>
5151
*/
52-
private static final Pattern SELECTOR = Pattern.compile("([>~+\\-, ]*)?((?:(?:\\w+|\\*)\\|)?(?:\\w+(?:\\\\.\\w+)?|\\*))?(?:#(\\w+))?((?:\\.\\w+)*)(?:\\[\\s?([\\w:]+)(?:\\s*([=~^$*|])?=\\s*[\"]([^\"]*)[\"])?\\s?\\])?(?::([\\w-]+)(?:\\((odd|even|(\\d*)(n)?(?:\\+(\\d+))?|(?:.*))\\))?)?");
52+
private static final Pattern SELECTOR = Pattern.compile("([>~+\\-, ]*)?((?:(?:\\w+|\\*)\\|)?(?:\\w+(?:\\\\.\\w+)*|\\*))?(?:#(\\w+))?((?:\\.\\w+)*)(?:\\[\\s?([\\w:]+)(?:\\s*([=~^$*|])?=\\s*[\"]([^\"]*)[\"])?\\s?\\])?(?::([\\w-]+)(?:\\((odd|even|(\\d*)(n)?(?:\\+(\\d+))?|(?:.*))\\))?)?");
5353

5454
/** The cache for compiled selectors. */
5555
private static final Map<String, XPathExpression> selectors = new ConcurrentHashMap();

src/test/java/kiss/xml/ElementFindTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ public void types() throws Exception {
3636

3737
@Test
3838
public void typeWithDot() throws Exception {
39-
String xml = "<m><E.E/></m>";
39+
String xml = "<m><E.E.E/></m>";
4040

41-
assert $(xml).find("E\\.E").size() == 1;
41+
assert $(xml).find("E\\.E\\.E").size() == 1;
4242
}
4343

4444
@Test

0 commit comments

Comments
 (0)