directory-api mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lécharny <elecha...@gmail.com>
Subject Re: DN parsing troubles...
Date Thu, 08 Oct 2015 08:14:46 GMT
Le 08/10/15 09:52, Emmanuel Lécharny a écrit :
> Hi guys,
>
> I'm reviewing the DN Parser, as I think we are overdoing. So far, I have
> something that works, except a couple of tests that fail. One otf them is :
>
>     public void testRdnWithEscapedComa() throws LdapException
>     {
>         ...
>         Rdn rdn = new Rdn( "a=\"b\\,c\"" );
>         assertEquals( "a=\"b\\,c\"", rdn.getName() );
>         assertEquals( "a=b\\,c", rdn.getNormName() );   // WRONG !!!
>
> Here, I think the test is wrong. The initial value is surrounded by
> quotes, which means that we don't need to escape special chars like ','
> into it. Actually, the following value is accepted :
>
>     Rdn rdn1 = new Rdn( "a=b\\,c" );
>
> and the RDN value is 'b,c' (the ',' is escaped to avoid a confusion with
> the next RDN in a DN)
>
> but when we use quotes, this is equivalent to :
>
>     Rdn rdn2 = new Rdn( "a=\"b,c\"" );
>
> Here rdn1 <==> rdn2 (or it should be equivalent.
>
> On the other hand, this rdn :
>
>     Rdn rdn3 = new Rdn( "a=\"b\\,c\"" );
>
> should be equivalent to :
>
>     Rdn rdn4 = new Rdn( "a=b\\\,c" );
>
> where we must keep an escaped escape and an escaped coma.
>
> Thoughts ?
btw, the correct test should be :

    /**
     * test an Rdn with escaped comma
     */
    @Test
    public void testRdnWithEscapedComa() throws LdapException
    {
        ...

        assertTrue( Rdn.isValid( "a=\"b\\,c\"" ) );
        Rdn rdn = new Rdn( "a=\"b\\,c\"" );
        assertEquals( "a=\"b\\,c\"", rdn.getName() );
        assertEquals( "a=b\\\\\\,c", rdn.getNormName() );  // <<----
This has been changed
    }



Mime
View raw message