directory-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hammond, Steve" <>
Subject RE: [ApacheDS] Parsing question FilterParser
Date Thu, 10 Jul 2008 05:08:54 GMT
The unit test for my assumption is          
ExprNode x = FilterParser.parse("(memberOf=1.2.840.113556.1.4.1301=$#@&*\\28\\29==,,,");

Unit test is code I borrowed from apacheds/core/src/test/java/org/apache/directory/server/core/subtree/
         SubtreeEvaluator evaluator = new SubtreeEvaluator( testCore.getRegistries().getOidRegistry(),
testCore.getRegistries().getAttributeTypeRegistry() );
         ExprNode filter = FilterParser.parse( "(&(cn=bob \\28the builder\\29)(objectClass=person))"

         SubtreeSpecificationModifier modifier = new SubtreeSpecificationModifier();
         modifier.setRefinement( filter );
         modifier.setMinBaseDistance( 1 );
         modifier.setMaxBaseDistance( 3 );
         modifier.setBase( new LdapDN( "ou=users" ) );
         SubtreeSpecification ss = modifier.getSubtreeSpecification();
         LdapDN apDn = new LdapDN( "ou=system" );
         LdapDN entryDn = new LdapDN( "ou=users,ou=system" );

         ServerEntry entry = new DefaultServerEntry( testCore.getRegistries(), entryDn );;
         entry.put( "objectClass", "person" );
         entry.put( "cn", "bob (the builder)" );

         assertFalse( evaluator.evaluate( ss, apDn, entryDn, entry ) );

         entryDn = new LdapDN( "cn=bob (the builder),ou=users,ou=system" );
         assertTrue( evaluator.evaluate( ss, apDn, entryDn, entry ) );

-----Original Message-----
From: Emmanuel Lecharny [] On Behalf Of Emmanuel Lecharny
Sent: Wednesday, July 09, 2008 6:15 PM
Subject: Re: [ApacheDS] Parsing question FilterParser

Hammond, Steve wrote:
> I am still having problems with parenthesis.
> If I do a search thru LdapStudio against my own partition for (cn=bob
> (just bob)) escaped as (cn=bob \28just bob\29), things work great.  My
> class gets passed a SearchOpContext with the filter
> having the parenthesis unescaped already for me.
> If I try to do a unit test case or code that passes in a filter as a
> string, FilterParser.parse() handles the escaped string, but does not
> unescape the parenthesis as I expected, so my gets an
> OpConext with the filter having \28 and \29 in it so my unit test fails.
> Is there a reason FilterParser.parse is not unescaping these values for
> me?  Is there a hidden ExprNode.unescape() function that I should be
> calling?  Or do I have to have special cases to handle these escapes in
> all of my partition entry points?
Can you paste your unit test ?

It's a little bit late here (2 am, Paris time) and my brain is not in 
good shape :)

I will try to give you an ansswer tomorrow morning.

Thanks !

cordialement, regards,
Emmanuel L├ęcharny

View raw message