You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Stefan Seelmann <se...@apache.org> on 2008/06/01 11:11:07 UTC

openldap.g schema parser prefixes double quotes with a backslash

Hi,

In testAttributeTypeParseWithDescQuotes() of OpenLdapSchemaParserTest
(http://tinyurl.com/58nhpm) the DESC element contains two double quotes:

  ... DESC 'RFC2256: \"knowledge\" information'\n" ...

The parser in openldap.g adds a backslash before each double quote and
this is also expected in the test:

  assertEquals( "RFC2256: \\\"knowledge\\\" information",
type.getDescription() );

I just wonder what's the reason for adding a backslash?

Regards,
Stefan



Re: openldap.g schema parser prefixes double quotes with a backslash

Posted by Emmanuel Lecharny <el...@apache.org>.
Stefan Seelmann wrote:
> Hi,
>
> I know the reason why the parser add an additional backslash before each
> double quote. The velocity templates of the apacheds-core-plugin
> generate java classes and write the parsed DESC as String literal,
> double qoutes in that literal must be escaped of course. I fixed that by
> escaping double quotes locally in the velocity templates rather than in
> the schema parser.
>   
Ok, thanks for having invastigated this point, Stefan. I wasn't able to 
do so as I'm not in front of my computer, but using gmail on a 
unfriendly (to me ;) OS...

Will be back on track on monday afternoon !

-- 
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org



Re: openldap.g schema parser prefixes double quotes with a backslash

Posted by Stefan Seelmann <se...@apache.org>.
Hi,

I know the reason why the parser add an additional backslash before each
double quote. The velocity templates of the apacheds-core-plugin
generate java classes and write the parsed DESC as String literal,
double qoutes in that literal must be escaped of course. I fixed that by
escaping double quotes locally in the velocity templates rather than in
the schema parser.

Kind Regards,
Stefan


Stefan Seelmann schrieb:
> Emmanuel Lecharny wrote
>> On Sun, Jun 1, 2008 at 11:11 AM, Stefan Seelmann <se...@apache.org> wrote:
>>> Hi,
>>>
>>> In testAttributeTypeParseWithDescQuotes() of OpenLdapSchemaParserTest
>>> (http://tinyurl.com/58nhpm) the DESC element contains two double quotes:
>>>
>>>  ... DESC 'RFC2256: \"knowledge\" information'\n" ...
> 
> Oh, I sould say that this is part of a Java String, so \" is transformed
> to a ". Here is the complete String:
> 
> String attributeTypeData = "# adding a comment  \n" + "attributetype (
> 2.5.4.2 NAME 'knowledgeInformation'\n"
>             + "        DESC 'RFC2256: \"knowledge\" information'\n" + "
>        EQUALITY caseIgnoreMatch\n"
>             + "        SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} )";
> 
>>> The parser in openldap.g adds a backslash before each double quote and
>>> this is also expected in the test:
>>>
>>>  assertEquals( "RFC2256: \\\"knowledge\\\" information",
>>> type.getDescription() );
>>>
>>> I just wonder what's the reason for adding a backslash?
>> Because otherwise, the two strings wont be equal :)
>>
>> The first \\ in the assert will be transformed into a \ internally.
>> The following \" is transformed to a "
>> This result to a \" internally, to be compared with the original DESC,
>> containing \".
>>
> 
> See my comment above. The DESC of attributeTypeData only contains a
> double quoute " without any backslash in front.


Re: openldap.g schema parser prefixes double quotes with a backslash

Posted by Stefan Seelmann <se...@apache.org>.
Emmanuel Lecharny wrote
> On Sun, Jun 1, 2008 at 11:11 AM, Stefan Seelmann <se...@apache.org> wrote:
>> Hi,
>>
>> In testAttributeTypeParseWithDescQuotes() of OpenLdapSchemaParserTest
>> (http://tinyurl.com/58nhpm) the DESC element contains two double quotes:
>>
>>  ... DESC 'RFC2256: \"knowledge\" information'\n" ...

Oh, I sould say that this is part of a Java String, so \" is transformed
to a ". Here is the complete String:

String attributeTypeData = "# adding a comment  \n" + "attributetype (
2.5.4.2 NAME 'knowledgeInformation'\n"
            + "        DESC 'RFC2256: \"knowledge\" information'\n" + "
       EQUALITY caseIgnoreMatch\n"
            + "        SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} )";

>>
>> The parser in openldap.g adds a backslash before each double quote and
>> this is also expected in the test:
>>
>>  assertEquals( "RFC2256: \\\"knowledge\\\" information",
>> type.getDescription() );
>>
>> I just wonder what's the reason for adding a backslash?
> 
> Because otherwise, the two strings wont be equal :)
> 
> The first \\ in the assert will be transformed into a \ internally.
> The following \" is transformed to a "
> This result to a \" internally, to be compared with the original DESC,
> containing \".
> 

See my comment above. The DESC of attributeTypeData only contains a
double quoute " without any backslash in front.

Re: openldap.g schema parser prefixes double quotes with a backslash

Posted by Emmanuel Lecharny <el...@gmail.com>.
On Sun, Jun 1, 2008 at 11:11 AM, Stefan Seelmann <se...@apache.org> wrote:
> Hi,
>
> In testAttributeTypeParseWithDescQuotes() of OpenLdapSchemaParserTest
> (http://tinyurl.com/58nhpm) the DESC element contains two double quotes:
>
>  ... DESC 'RFC2256: \"knowledge\" information'\n" ...
>
> The parser in openldap.g adds a backslash before each double quote and
> this is also expected in the test:
>
>  assertEquals( "RFC2256: \\\"knowledge\\\" information",
> type.getDescription() );
>
> I just wonder what's the reason for adding a backslash?

Because otherwise, the two strings wont be equal :)

The first \\ in the assert will be transformed into a \ internally.
The following \" is transformed to a "
This result to a \" internally, to be compared with the original DESC,
containing \".



-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com