Issue 1776: Notification email subject gets spurious LF character when template is not ending with a macro
Status:  New
Owner: ----
Reported by marcin.c...@gmail.com, Feb 3, 2013
************************************************************
***** NOTE: THIS BUG TRACKER IS FOR GERRIT CODE REVIEW *****
***** DO NOT SUBMIT BUGS FOR CHROME, ANDROID, INTERNAL *****
***** ISSUES WITH YOUR COMPANY'S GERRIT SETUP, ETC.    *****
***** THOSE ISSUE BELONG IN DIFFERENT ISSUE TRACKERS!  *****
************************************************************

Affected Version:

Running 2.6-master ef6b83bd204b028191f9e0e65e4e5ea83192422f

What steps will reproduce the problem?
1. Modify etc/mail/ChangeSubject.vm not to have a macro call at the end,
for example change the list line to:

Some change $change.subject                                                                                                                                   

or some literal string.
2. Add an reviewer to the change other than the submitter
3. Trigger notification (new change for example)

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

Subject line received:

Subject: =?UTF-8?Q?Some_change_bogus_line_2_Chg=0A?=

displayed by my user agent as:

Subject: Some change bogus line 2 Chg^J

Should be:

Subject: Some change bogus line 2 Chg

without a spurious 0A (LF) character at the end
and possibly not encoded to quoted printable
(if this is not necessary due to some other reson).

Please provide any additional information below.

This is related to the non-uniform way how Velocity
treats whitespaces during processing. There is
a tracking bug for this:

https://issues.apache.org/jira/browse/VELOCITY-253

There is a workaround for this issue - to use 
a macro:

#macro(plain $str)$str#end
Some change #plain($change.subject)

Feb 5, 2013
Project Member #1 david.pu...@sonymobile.com
Is this reproducible with the templates as-is from the Gerrit installation, or only if they are modified as in the example?

Feb 5, 2013
#2 marcin.c...@gmail.com
No, a stock ChangeSubject.vm included with Gerrit does not exhibit this problem, because it ends with a macro call. 

Other templates are multi-line templates (they create email bodies), so the problem is barely noticeable and probably has no impact. but this needs to be checked. For example whether putting macro at the end of the content template does not cause the footer to be appended without a new line:

Change body line 1
Change body line 2
Change body line 3Footer line 1

(didn't check)

Yes, to reproduce this one needs to modify site-level etc/mail/ChangeSubject.vm; no restart is necessary.