z4r / python-rtkit

Python Api for Request Tracker's REST interface
http://z4r.github.com/python-rtkit/
Other
68 stars 44 forks source link

RFC5322-like parsing failure #3

Closed user-none closed 12 years ago

user-none commented 12 years ago

The issue is In resource.py function _build.

Some of the ticket returned by RT have two dashes in the subject. When splitting based on -- these are being categorized as as new sections. This can also lead to exceptions being thrown in build_section when the area after -- has a space but logic_lines is empty.

E.G.

123: Data returned by RT -- has two dashes...

The solution I'm using is use a re to create the split. I've changed the last line in the file to:

return [build_section(b) for b in re.split('(?mu)^\s*--', body)]

This ensures that the --'s start the line with white space removed. multi-line is required to have ^ match at the beginning of the line but u probably isn't necessary.

user-none commented 12 years ago

Looking at a few more places such as history with format=l the regex needs to be tweaked. The line should be:

return [build_section(b) for b in re.split('(?mu)^--', body)]

I noticed I have content in some tickets with multiple -- but the RFC5322 delimitation always touched the start of the line and never has white space before.