Issue Details (XML | Word | Printable)

Key: DIR-184
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Emmanuel Lecharny
Reporter: Jacob S. Barrett
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Directory

DnParser does not correctly parse leading and trailing spaces and pound signs in values.

Created: 20/Apr/06 03:02 AM   Updated: 06/May/09 03:57 PM
Return to search
Component/s: None
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works DIR-184.patch 2006-04-20 06:45 AM Jacob S. Barrett 3 kB

Resolution Date: 21/Aug/06 09:52 PM


 Description  « Hide
As defined in RFC 2253 section 2.4:
(http://www.ietf.org/rfc/rfc2253.txt)
..
If the UTF-8 string does not have any of the following characters
   which need escaping, then that string can be used as the string
   representation of the value.

    - a space or "#" character occurring at the beginning of the
        string

    - a space character occurring at the end of the string

    - one of the characters ",", "+", """, "\", "<", ">" or ";"
...

A string can lead with '\ ' and trail with '\ '. Both cases are not supported by the DnParser and cause a parsing error. Furthermore, if a string starts with '\ ' only the spaces leading up to the escape should be trimmed. In addition only the spaces after '\ ' when at the end of a value should be stripped.

looking at the valuelexer.g file '\#' will work anywhere in the string, but should really only be supported at the head of the string.

If I understand the RFC correctly then these string should be supported:
"\ four spaces leading and 3 trailing \ " -> "\ four spaces leading and 3 trailing \ "
" \ two leading three trailing \ " -> "\ two leading three trailing \ "
"\# a leading pound" -> "\# a pound"
"a middle # pound" -> "a middle # pound"
"a trailing pound #" -> "a trailing pound #"

These are not valid:
"middle\ spaces"
"# a leading pound"
"a middle \# pound"
"a trailing pound \#"
Unless the next line in the RFC is really true, "Implementations MAY escape other characters." This makes things a bit more hairy I think.


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Jacob S. Barrett added a comment - 20/Apr/06 05:29 AM
Ignore my comments on the # sign. I am really confused on what the RFC means by leading #. The examples show a string with leading # to define BER octets, but it doesn't escape it, so I am confused.

There is still a problem with leading and trailing spaces.

Emmanuel Lecharny added a comment - 20/Apr/06 05:45 AM
Hi Jacob,

Jira had a problem lately, so it has lost my previous comment ... Hopefully, you added yours, so I wo'nt have to reply to the whole samples ;)

Regarding the spaces, and the 2.4 section, there is something confusing in RFC2253. If you read carefully the section 3, you will see that the gramar tells that there are no way to produce a DN with an attributeValue starting or ending with a '\ '. So this leads to the conclusion that section 2.4 and section 3 are contradictory.

wdyt ?

Jacob S. Barrett added a comment - 20/Apr/06 06:09 AM
I noticed that too, but I am working with names returned by Novell eDirectory and it certainly supports this. I would say the more verbose plain english description is the more "correct". I haven't tested with other directories yet.

Emmanuel Lecharny added a comment - 20/Apr/06 06:27 AM
What we can do is to allow those leading and trailing '\ ', accordingly to the text : "Implementations MAY escape other characters."

A good solution could be to implement this document : http://www.ietf.org/proceedings/01aug/I-D/draft-ietf-ldapbis-dn-06.txt

It's section 2.4 states :
"... Alternatively, if and only if the character to be escaped
  is one of

      ",", "+", """, "\", "<", ">", ";", "#", "=", or " " <----- (has been added to RFC2253)
      (ASCII 44, 43, 34, 92, 60, 62, 59, 35, or 32, respectively)

  it can be prefixed by a backslash ('\' ASCII 92). ..."

So the " " can be escaped.

Could you modify the JIRA report to be an improvment instead of a Major Bug?

Jacob S. Barrett added a comment - 20/Apr/06 06:45 AM
Here is a patch that fixes the spaces problem. It might not be the cleanest solution, but I had to just get something working ASAP.

Basically it keeps track of the non-space (which includes escaped spaces) and spaces separately. If no non-spaces have been parsed it ignores spaces (trims the leading spaces). When done if there are spaces after the last non-space then they are removed (trims trailing spaces).

I am sure there is a cleaner grammer to describe this, but like I said, I don't have the time.

Jacob S. Barrett made changes - 20/Apr/06 06:45 AM
Field Original Value New Value
Attachment DIR-184.patch [ 12325582 ]
Emmanuel Lecharny added a comment - 08/Jul/06 03:15 PM
This has been fixed and tested.
It will be released in 1.0-RC4.

Emmanuel Lecharny made changes - 08/Jul/06 03:15 PM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
Assignee Alex Karasulu [ akarasulu ] Emmanuel Lecharny [ elecharny ]
Emmanuel Lecharny added a comment - 21/Aug/06 09:52 PM
I reopen the issue because # should *not*ù be escaped in the middle of a DN.

legal values :
dn=\#sharp at the beginning
dn=sharp at the # middle
dn=sharp at the end #

illegal values
dn=#sharp at the beginning
dn=sharp at the \# middle
dn=sharp at the end \#


Emmanuel Lecharny made changes - 21/Aug/06 09:52 PM
Resolution Fixed [ 1 ]
Status Resolved [ 5 ] Reopened [ 4 ]
Emmanuel Lecharny added a comment - 21/Aug/06 09:52 PM
Fixed as it was breaking one of the DIRSERVER-631 tests.

Emmanuel Lecharny made changes - 21/Aug/06 09:52 PM
Resolution Fixed [ 1 ]
Status Reopened [ 4 ] Resolved [ 5 ]
Repository Revision Date User Message
ASF #433388 Mon Aug 21 22:01:42 UTC 2006 elecharny Modified the STRING_CHAR table to allow a '#' in the middle of a dn
It will fix one error in DIRSERVER-631, and fix DIR-184
Files Changed
MODIFY /directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/util/DNUtils.java

Repository Revision Date User Message
ASF #433389 Mon Aug 21 22:02:35 UTC 2006 elecharny - Renamed DIRSERVER-184 to DIR-184
- fixed the tests where a # in the middle or at the end
of a DN was escaped. This was wrong.
Files Changed
MODIFY /directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java

Emmanuel Lecharny made changes - 06/May/09 03:57 PM
Status Resolved [ 5 ] Closed [ 6 ]