changeset 2559:1362cabad225

plugin merge-request mercurial: better name sanitization for import
author Goffi <goffi@goffi.org>
date Mon, 02 Apr 2018 08:45:08 +0200
parents 501b0f827f63
children 6a31c67c562f
files src/plugins/plugin_merge_req_mercurial.py
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/plugin_merge_req_mercurial.py	Mon Apr 02 08:23:22 2018 +0200
+++ b/src/plugins/plugin_merge_req_mercurial.py	Mon Apr 02 08:45:08 2018 +0200
@@ -23,6 +23,7 @@
 from twisted.internet import reactor, defer, protocol
 from twisted.python.failure import Failure
 from twisted.python.procutils import which
+import re
 from sat.core.log import getLogger
 log = getLogger(__name__)
 
@@ -130,7 +131,7 @@
         parsed_data = self.parse(data)
         try:
             parsed_name = parsed_data[0][u'commit_msg'].split(u'\n')[0]
-            parsed_name = parsed_name.replace(u' ', u'_')[:20]
+            parsed_name = re.sub(ur'[^\w-]', u'', parsed_name, flags=re.UNICODE)[:20]
         except Exception:
             parsed_name = u''
         name = u'mr_{item_id}_{parsed_name}'.format(item_id=item_id, parsed_name=parsed_name)