Bug 53997 - LDAP Extended Request: Escape ampersand (&), left angle bracket (<) and right angle bracket (>) in search filter tag in XML response data
LDAP Extended Request: Escape ampersand (&), left angle bracket (<) and right...
Status: RESOLVED FIXED
Product: JMeter
Classification: Unclassified
Component: Main
2.8
All All
: P2 normal (vote)
: ---
Assigned To: JMeter issues mailing list
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2012-10-12 17:06 UTC by Mark Miller
Modified: 2012-10-13 17:23 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Miller 2012-10-12 17:06:55 UTC
When LDAP sampler includes an AND (&) operator in the LDAP filter, this filter value is echoed in the XML response data. 

The ampersand character is not escaped in the xml. 

In the XML the filter will appear in its original form:
(&(sn=smith)(givenName=dave))

Then, attempts to process the response data as XML (XPath assertions, extractors, etc) fail to parse the XML and generate errors. 

As a workaround, I use a jruby postprocessor:
res = $prev.getResponseDataAsString()
res.gsub!("&","&amp;")#the ampersand breaks the xml so encode it
$prev.setResponseData(res,"utf-8")

Pre Correction
<searchfilter>(&(objectclass=x-commonProfile)(sn=Millerp)(givenName=Markp)(x-emailAddress1=26e7b5b3@yopmail.com))</searchfilter>

Post Correction
<searchfilter>(&amp;(objectclass=x-commonProfile)(sn=Millerp)(givenName=Markp)(x-emailAddress1=26e7b5b3@yopmail.com))</searchfilter>

Once corrected, other XML based operations are successful. 

Considering that the character is valid and predictable in the LDAP context, I consider this a bug (even though the workaround is fairly trivial).
Comment 1 Milamber 2012-10-13 16:12:37 UTC
Thanks for report.
Fixed in trunk.


URL: http://svn.apache.org/viewvc?rev=1397875&view=rev
Log:
LDAP Extended Request: Escape ampersand (&), left angle bracket (<) and right angle bracket (>) in search filter tag in XML response data
Bugzilla Id: 53997

Modified:
    jmeter/trunk/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LDAPExtSampler.java
    jmeter/trunk/xdocs/changes.xml
Comment 2 Milamber 2012-10-13 16:13:30 UTC

For reference:
http://www.w3.org/TR/2000/REC-xml-20001006#syntax
Comment 3 Milamber 2012-10-13 17:23:34 UTC
Thanks Philippe!

URL: http://svn.apache.org/viewvc?rev=1397905&view=rev
Log:
Better way
LDAP Extended Request: Escape ampersand (&), left angle bracket (<) and right angle bracket (>) in search filter tag in XML response data
Bugzilla Id: 53997

Modified:
    jmeter/trunk/src/protocol/ldap/org/apache/jmeter/protocol/ldap/sampler/LDAPExtSampler.java