While converting CSS class selectors into XPath expressions white spaces are not correctly handled: the current code appends a starting space and trailing one to the class attribute value and does the same with the class value being processed. This approach works only if there is only a space separating every class value, but in more complex cases the resulting XPath expressions does not select element the should be matched, e.g.:

<style type="text/css">
  <!--
    .value1 {
      background: red;
    }
  -->
</style>

<!-- a newline is separating the class values! -->
<body class="value1 
value2">
...
</body>

In this case the body element is not matched by the following XPath expression:

//*[contains(concat(" ",@class," "),concat(" ","value1"," "))]
CommentFileSizeAuthor
#1 mimemail-729334-1.patch926 bytesplach

Comments

plach’s picture

Status: Active » Needs review
StatusFileSize
new926 bytes

The attached patch should fix the issue by normalizing white spaces in the class attribute value.

sgabe’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Needs review » Reviewed & tested by the community

I can confirm this issue. The patch works as advertised.

sgabe’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.