Thanks for the test.

What happens is that the Parser does not normalize or unescape the value. It simply reject invalid filters.

The normalization/escaping is done in the NormalizationInterceptor :

public NamingEnumeration<ServerSearchResult> search( NextInterceptor nextInterceptor, SearchOperationContext opContext ) throws NamingException
   {
       ExprNode filter = opContext.getFilter();
       opContext.getDn().normalize( attrNormalizers );
       ExprNode result = ( ExprNode ) filter.accept( normVisitor );
       ...

I need to do some more test to check that the filter is correctly handled with escaped chars in this method, will get you informed.

Thanks !

Hammond, Steve wrote:
The unit test for my assumption is ExprNode x = FilterParser.parse("(memberOf=1.2.840.113556.1.4.1301=$#@&*\\28\\29==,2.5.4.11=local,2.5.4.11=users,2.5.4.11=readimanager)"); assertEquals("(memberOf=1.2.840.113556.1.4.1301=$#@&*{}==,2.5.4.11=local,2.5.4.11=users,2.5.4.11=readimanager)", x.toString());

Unit test is code I borrowed from 
apacheds/core/src/test/java/org/apache/directory/server/core/subtree/SubtreeEvaluatorTest.java
         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 [mailto:[EMAIL PROTECTED] On Behalf Of Emmanuel Lecharny
Sent: Wednesday, July 09, 2008 6:15 PM
To: [email protected]
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
partition.search 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 partition.search 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
www.iktek.com
directory.apache.org


Reply via email to