Fix the ascii encode issue about sending mail
authorZhuoX Li <zhuox.li@intel.com>
Fri, 27 Jun 2014 08:12:39 +0000 (16:12 +0800)
committerLin Yang <lin.a.yang@intel.com>
Mon, 7 Jul 2014 09:07:22 +0000 (17:07 +0800)
When we send mail to submitter,need a specific format of address
in job_request.py.Sometimes it maybe have the escape character,
that causes the encode issue.We should check and change it.
eg:
  '&lt;stephane.desneux@open.eurogiciel.org&gt;' should be changed to
  '<stephane.desneux@open.eurogiciel.org>'

Fixes: #2010

Change-Id: Ib0d1b0c32f37a2a1f007ac8bc5e319f98f1175db

job_request.py

index a98db08..c6d7cce 100755 (executable)
@@ -95,7 +95,11 @@ def obs_git_data(event_fields):
                     mkey = mapping.get(key.strip())
                     if not mkey:
                         continue
-                    entry[mkey] = value.strip()
+                    if key.strip() in ['Submitter']:
+                        entry[mkey] = value.strip().replace('&lt;',
+                                                    '<').replace('&gt;', '>')
+                    else:
+                        entry[mkey] = value.strip()
                 except (AttributeError, ValueError):
                     print '-------------------------------------'
                     print 'key:value  %s' % line