1689: post-review --guess-summary should trim internal newlines

tsto****@gmai***** (Google Code) (Is this you? Claim this profile.)
Sept. 6, 2011
What version are you running?
post-review --version: RBTools 0.2
Reviewboard server:
git --version:

What's the URL of the page containing the problem?

What steps will reproduce the problem?
1. Create a git branch from a git-svn base
2. Make >=2 new git commits on this git branch, where each commit log is of the form:
First line\n
<blank line>\n
second line...
3. post-review --revision-range=HEAD^^:HEAD --guess-summary ...

What is the expected output? What do you see instead?

The --guess-summary option takes the first line from each (2) commit message, and concatenates. However, the newlines are not being stripped. This results in django errors being emailed to the administrator when the review is posted (and an error in the web browser).

Traceback (most recent call last):

  File "/usr/local/lib/python2.6/dist-packages/Django-1.1.1-py2.6.egg/django/core/handlers/base.py",
line 92, in get_response
    response = callback(request, *callback_args, **callback_kwargs)

  File "/usr/local/lib/python2.6/dist-packages/Django-1.1.1-py2.6.egg/django/views/decorators/cache.py",
line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)

  File "/usr/local/lib/python2.6/dist-packages/Djblets-0.5.5-py2.6.egg/djblets/webapi/decorators.py",
line 59, in _checklogin
    response = view_func(request, *args, **kwargs)

  File "/usr/local/lib/python2.6/dist-packages/ReviewBoard-",
line 520, in review_request_publish

  File "/usr/local/lib/python2.6/dist-packages/ReviewBoard-",
line 458, in publish
    mail_review_request(user, self, changes)

  File "/usr/local/lib/python2.6/dist-packages/ReviewBoard-",
line 184, in mail_review_request

  File "/usr/local/lib/python2.6/dist-packages/ReviewBoard-",
line 114, in send_review_mail

  File "/usr/local/lib/python2.6/dist-packages/Django-1.1.1-py2.6.egg/django/core/mail.py",
line 266, in send
    return self.get_connection(fail_silently).send_messages([self])

  File "/usr/local/lib/python2.6/dist-packages/Django-1.1.1-py2.6.egg/django/core/mail.py",
line 172, in send_messages
    sent = self._send(message)

  File "/usr/local/lib/python2.6/dist-packages/Django-1.1.1-py2.6.egg/django/core/mail.py",
line 186, in _send

  File "/usr/local/lib/python2.6/dist-packages/ReviewBoard-",
line 41, in message
    msg = super(SpiffyEmailMessage, self).message()

  File "/usr/local/lib/python2.6/dist-packages/Django-1.1.1-py2.6.egg/django/core/mail.py",
line 238, in message
    msg['Subject'] = self.subject

  File "/usr/local/lib/python2.6/dist-packages/Django-1.1.1-py2.6.egg/django/core/mail.py",
line 96, in __setitem__
    name, val = forbid_multi_line_headers(name, val)

  File "/usr/local/lib/python2.6/dist-packages/Django-1.1.1-py2.6.egg/django/core/mail.py",
line 76, in forbid_multi_line_headers
    raise BadHeaderError("Header values can't contain newlines (got %r
for header %r)" % (val, name))

BadHeaderError: Header values can't contain newlines (got u'Review
Request: First line commit 1\nFirst line commit 2' for
header 'Subject')

What operating system are you using? What browser?
Linux (ubuntu) client and server. Firefox, not that it matters.

Please provide any additional information below.

GET:<QueryDict: {}>,
POST:<QueryDict: {u'dummy': [u'']}>,
COOKIES:{'collapsediffs': 'True', 'rbsessionid':
 'CONTENT_TYPE': 'application/x-www-form-urlencoded; charset=UTF-8',
 'HTTP_ACCEPT': 'application/json, text/javascript, */*',
 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
 'HTTP_ACCEPT_ENCODING': 'gzip,deflate',
 'HTTP_ACCEPT_LANGUAGE': 'en-us,en;q=0.5',
 'HTTP_CACHE_CONTROL': 'no-cache',
 'HTTP_CONNECTION': 'keep-alive',
 'HTTP_CONTENT_TYPE': 'application/x-www-form-urlencoded; charset=UTF-8',
 'HTTP_COOKIE': 'rbsessionid=acceb746e620d983a1c03a08322cbcff;
 'HTTP_KEEP_ALIVE': '300',
 'HTTP_PRAGMA': 'no-cache',
 'HTTP_REFERER': 'http://XXX/r/267/diff/?page=3',
 'HTTP_USER_AGENT': 'Mozilla/5.0 (X11; U; Linux x86_64; en-US;
rv: Gecko/20100402 Ubuntu/9.10 (karmic) Firefox/3.5.9',
 'PATH_INFO': u'/api/json/reviewrequests/267/publish/',
 'REMOTE_ADDR': 'xxx',
 'SERVER_NAME': 'xxx',
 'SERVER_SOFTWARE': 'mod_python'}>

Re-pressing the publish button seems to make it work, but emails are not sent.
#1 paul*****@gmai***** (Google Code) (Is this you? Claim this profile.)
This is a fairly epic problem, as most commits contain newlines and other important information. 
#3 david
Fixed in master (4ee9be4).
  • +Fixed
#4 Alexande*********@gmai***** (Google Code) (Is this you? Claim this profile.)
I'm still running into this issue even with RBTools 0.4.1:

>>> Attempting to set field 'summary' to 'Product: Fixed layout.
' for review request '11405'
>>> HTTP PUTting to http://my.server.com/api/review-requests/11405/draft/: {'summary': 'Product: Fixed layout.\n'}
>>> Got API Error 105 (HTTP code 400): One or more fields had errors
>>> Error data: {u'fields': {u'summary': [u'Summary cannot contain newlines']}

Should I file a separate issue for this?
#5 Alexande*********@gmai***** (Google Code) (Is this you? Claim this profile.)
Filed http://code.google.com/p/reviewboard/issues/detail?id=2703