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

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

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-1.0.5.1-py2.6.egg/reviewboard/webapi/json.py",
line 520, in review_request_publish
    review_request.publish(request.user)

  File "/usr/local/lib/python2.6/dist-packages/ReviewBoard-1.0.5.1-py2.6.egg/reviewboard/reviews/models.py",
line 458, in publish
    mail_review_request(user, self, changes)

  File "/usr/local/lib/python2.6/dist-packages/ReviewBoard-1.0.5.1-py2.6.egg/reviewboard/reviews/email.py",
line 184, in mail_review_request
    extra_context)

  File "/usr/local/lib/python2.6/dist-packages/ReviewBoard-1.0.5.1-py2.6.egg/reviewboard/reviews/email.py",
line 114, in send_review_mail
    message.send()

  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
    email_message.message().as_string())

  File "/usr/local/lib/python2.6/dist-packages/ReviewBoard-1.0.5.1-py2.6.egg/reviewboard/reviews/email.py",
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.

<ModPythonRequest
path:/api/json/reviewrequests/267/publish/,
GET:<QueryDict: {}>,
POST:<QueryDict: {u'dummy': [u'']}>,
COOKIES:{'collapsediffs': 'True', 'rbsessionid':
'acceb746e620d983a1c03a08322cbcff'},
META:{'AUTH_TYPE': None,
 'CONTENT_LENGTH': '6',
 'CONTENT_TYPE': 'application/x-www-form-urlencoded; charset=UTF-8',
 'GATEWAY_INTERFACE': 'CGI/1.1',
 '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_LENGTH': '6',
 'HTTP_CONTENT_TYPE': 'application/x-www-form-urlencoded; charset=UTF-8',
 'HTTP_COOKIE': 'rbsessionid=acceb746e620d983a1c03a08322cbcff;
collapsediffs=True',
 'HTTP_HOST': 'XXX',
 '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:1.9.1.9) Gecko/20100402 Ubuntu/9.10 (karmic) Firefox/3.5.9',
 'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest',
 'PATH_INFO': u'/api/json/reviewrequests/267/publish/',
 'PATH_TRANSLATED': None,
 'QUERY_STRING': None,
 'REMOTE_ADDR': 'xxx',
 'REMOTE_HOST': None,
 'REMOTE_IDENT': None,
 'REMOTE_USER': None,
 'REQUEST_METHOD': 'POST',
 'SCRIPT_NAME': '',
 'SERVER_NAME': 'xxx',
 'SERVER_PORT': 80,
 'SERVER_PROTOCOL': 'HTTP/1.1',
 '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. 
david
#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