~ubuntu-branches/debian/sid/subversion/sid

« back to all changes in this revision

Viewing changes to tools/hook-scripts/mailer/mailer.py

  • Committer: Package Import Robot
  • Author(s): James McCoy
  • Date: 2015-08-07 21:32:47 UTC
  • mfrom: (0.2.15) (4.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20150807213247-ozyewtmgsr6tkewl
Tags: 1.9.0-1
* Upload to unstable
* New upstream release.
  + Security fixes
    - CVE-2015-3184: Mixed anonymous/authenticated path-based authz with
      httpd 2.4
    - CVE-2015-3187: svn_repos_trace_node_locations() reveals paths hidden
      by authz
* Add >= 2.7 requirement for python-all-dev Build-Depends, needed to run
  tests.
* Remove Build-Conflicts against ruby-test-unit.  (Closes: #791844)
* Remove patches/apache_module_dependency in favor of expressing the
  dependencies in authz_svn.load/dav_svn.load.
* Build-Depend on apache2-dev (>= 2.4.16) to ensure ap_some_authn_required()
  is available when building mod_authz_svn and Depend on apache2-bin (>=
  2.4.16) for runtime support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#
23
23
# mailer.py: send email describing a commit
24
24
#
25
 
# $HeadURL: http://svn.apache.org/repos/asf/subversion/branches/1.8.x/tools/hook-scripts/mailer/mailer.py $
26
 
# $LastChangedDate: 2013-04-12 07:44:37 +0000 (Fri, 12 Apr 2013) $
 
25
# $HeadURL: http://svn.apache.org/repos/asf/subversion/branches/1.9.x/tools/hook-scripts/mailer/mailer.py $
 
26
# $LastChangedDate: 2015-02-13 11:17:40 +0000 (Fri, 13 Feb 2015) $
27
27
# $LastChangedBy: rhuijben $
28
 
# $LastChangedRevision: 1467191 $
 
28
# $LastChangedRevision: 1659509 $
29
29
#
30
30
# USAGE: mailer.py commit      REPOS REVISION [CONFIG-FILE]
31
31
#        mailer.py propchange  REPOS REVISION AUTHOR REVPROPNAME [CONFIG-FILE]
236
236
                               and self.reply_to[2] == ']':
237
237
      self.reply_to = self.reply_to[3:]
238
238
 
 
239
  def _rfc2047_encode(self, hdr):
 
240
    # Return the result of splitting HDR into tokens (on space
 
241
    # characters), encoding (per RFC2047) each token as necessary, and
 
242
    # slapping 'em back to together again.
 
243
    from email.Header import Header
 
244
 
 
245
    def _maybe_encode_header(hdr_token):
 
246
      try:
 
247
        hdr_token.encode('ascii')
 
248
        return hdr_token
 
249
      except UnicodeError:
 
250
        return Header(hdr_token, 'utf-8').encode()
 
251
 
 
252
    return ' '.join(map(_maybe_encode_header, hdr.split()))
 
253
 
239
254
  def mail_headers(self, group, params):
240
255
    from email import Utils
241
 
    subject = self.make_subject(group, params)
242
 
    try:
243
 
      subject.encode('ascii')
244
 
    except UnicodeError:
245
 
      from email.Header import Header
246
 
      subject = Header(subject, 'utf-8').encode()
247
 
    hdrs = 'From: %s\n'    \
248
 
           'To: %s\n'      \
 
256
 
 
257
    subject  = self._rfc2047_encode(self.make_subject(group, params))
 
258
    from_hdr = self._rfc2047_encode(self.from_addr)
 
259
    to_hdr   = self._rfc2047_encode(', '.join(self.to_addrs))
 
260
 
 
261
    hdrs = 'From: %s\n' \
 
262
           'To: %s\n' \
249
263
           'Subject: %s\n' \
250
264
           'Date: %s\n' \
251
265
           'Message-ID: %s\n' \
256
270
           'X-Svn-Commit-Author: %s\n' \
257
271
           'X-Svn-Commit-Revision: %d\n' \
258
272
           'X-Svn-Commit-Repository: %s\n' \
259
 
           % (self.from_addr, ', '.join(self.to_addrs), subject,
 
273
           % (from_hdr, to_hdr, subject,
260
274
              Utils.formatdate(), Utils.make_msgid(), group,
261
275
              self.repos.author or 'no_author', self.repos.rev,
262
276
              os.path.basename(self.repos.repos_dir))