]> www.vanbest.org Git - motioneye-debian/commitdiff
semicolons are now accepted in smtp account passwords
authorCalin Crisan <ccrisan@gmail.com>
Sat, 26 Dec 2015 14:24:58 +0000 (16:24 +0200)
committerCalin Crisan <ccrisan@gmail.com>
Sat, 26 Dec 2015 14:24:58 +0000 (16:24 +0200)
motioneye/config.py
motioneye/sendmail.py
motioneye/templates/main.html
motioneye/utils.py

index 2c3df86488fbe8687e7c3041d76835720484ed54..9e4900e3cd443c70f8980d080fbbf024819c4f47 100644 (file)
@@ -873,7 +873,7 @@ def motion_camera_ui_to_dict(ui, old_config=None):
                 'server': ui['email_notifications_smtp_server'],
                 'port': ui['email_notifications_smtp_port'],
                 'account': ui['email_notifications_smtp_account'],
-                'password': ui['email_notifications_smtp_password'],
+                'password': ui['email_notifications_smtp_password'].replace(';', '\\;'),
                 'tls': ui['email_notifications_smtp_tls'],
                 'to': emails,
                 'timespan': ui['email_notifications_picture_time_span']})
@@ -887,8 +887,7 @@ def motion_camera_ui_to_dict(ui, old_config=None):
                 'url': url})
 
     if ui['command_notifications_enabled']:
-        commands = ui['command_notifications_exec'].split(';')
-        on_event_start += [c.strip() for c in commands]
+        on_event_start += utils.split_semicolon(ui['command_notifications_exec'])
 
     data['on_event_start'] = '; '.join(on_event_start)
 
@@ -909,8 +908,7 @@ def motion_camera_ui_to_dict(ui, old_config=None):
                 'url': url})
 
     if ui['command_storage_enabled']:
-        commands = ui['command_storage_exec'].split(';')
-        on_movie_end += [c.strip() for c in commands]
+        on_movie_end += utils.split_semicolon(ui['command_storage_exec'])
 
     data['on_movie_end'] = '; '.join(on_movie_end)
     
@@ -926,8 +924,7 @@ def motion_camera_ui_to_dict(ui, old_config=None):
                 'url': url})
 
     if ui['command_storage_enabled']:
-        commands = ui['command_storage_exec'].split(';')
-        on_picture_save += [c.strip() for c in commands]
+        on_picture_save += utils.split_semicolon(ui['command_storage_exec'])
 
     data['on_picture_save'] = '; '.join(on_picture_save)
 
@@ -1230,7 +1227,7 @@ def motion_camera_dict_to_ui(data):
     # event start
     on_event_start = data.get('on_event_start') or []
     if on_event_start:
-        on_event_start = [e.strip() for e in on_event_start.split(';')]
+        on_event_start = utils.split_semicolon(on_event_start)
 
     ui['email_notifications_picture_time_span'] = 0
     command_notifications = []
@@ -1245,7 +1242,7 @@ def motion_camera_dict_to_ui(data):
             ui['email_notifications_smtp_server'] = e[-10]
             ui['email_notifications_smtp_port'] = e[-9]
             ui['email_notifications_smtp_account'] = e[-8]
-            ui['email_notifications_smtp_password'] = e[-7]
+            ui['email_notifications_smtp_password'] = e[-7].replace('\\;', ';')
             ui['email_notifications_smtp_tls'] = e[-6].lower() == 'true'
             ui['email_notifications_addresses'] = e[-5]
             try:
@@ -1277,7 +1274,7 @@ def motion_camera_dict_to_ui(data):
     # movie end
     on_movie_end = data.get('on_movie_end') or []
     if on_movie_end:
-        on_movie_end = [e.strip() for e in on_movie_end.split(';')]
+        on_movie_end = utils.split_semicolon(on_movie_end)
 
     command_storage = []
     for e in on_movie_end:
index 59efe64fcee58514baaf67ee6c8c6e98e2019c71..6dba6f19490fdbe53763109d057c5b9386e2410f 100644 (file)
@@ -168,6 +168,7 @@ def main(parser, args):
     message = messages.get(options.msg_id)
     subject = subjects.get(options.msg_id)
     options.moment = datetime.datetime.strptime(options.moment, '%Y-%m-%dT%H:%M:%S')
+    options.password = options.password.replace('\\;', ';') # unescape password
     
     # do not wait too long for media list,
     # email notifications are critical
index 6b35a8814d99b90ba25ba73d96e8be7214b2a098..b2f00085d5d38a85b5392e078c8de0f2b52c8d49 100644 (file)
                     <tr class="settings-item advanced-setting" required="true" depends="commandStorageEnabled" strip="true">
                         <td class="settings-item-label"><span class="settings-item-label">Command</span></td>
                         <td class="settings-item-value"><input type="text" class="styled storage camera-config" id="commandStorageEntry" placeholder="command..."></td>
-                        <td><span class="help-mark" title="a command to be executed after a media file is created; multiple commands can be separated by a semicolon; the following special tokens are accepted: %Y = year, %m = month, %d = date, %H = hour, %M = minute, %S = second, %f = file path">?</span></td>
+                        <td><span class="help-mark" title="a command to be executed after a media file is created; multiple commands can be separated by a semicolon; don't use semicolons inside commands; the following special tokens are accepted: %Y = year, %m = month, %d = date, %H = hour, %M = minute, %S = second, %f = file path">?</span></td>
                     </tr>
                     {% for config in camera_sections.get('storage', {}).get('configs', []) %}
                         {{config_item(config)}}
                     <tr class="settings-item advanced-setting" required="true" depends="commandNotificationsEnabled motionDetectionEnabled" strip="true">
                         <td class="settings-item-label"><span class="settings-item-label">Command</span></td>
                         <td class="settings-item-value"><input type="text" class="styled notifications camera-config" id="commandNotificationsEntry" placeholder="command..."></td>
-                        <td><span class="help-mark" title="a command to be executed when motion is detected; multiple commands can be separated by a semicolon; the following special tokens are accepted: %Y = year, %m = month, %d = date, %H = hour, %M = minute, %S = second, %q = frame number">?</span></td>
+                        <td><span class="help-mark" title="a command to be executed when motion is detected; multiple commands can be separated by a semicolon; don't use semilcolons inside commands; the following special tokens are accepted: %Y = year, %m = month, %d = date, %H = hour, %M = minute, %S = second, %q = frame number">?</span></td>
                     </tr>
                     {% for config in camera_sections.get('notifications', {}).get('configs', []) %}
                         {{config_item(config, "motionDetectionEnabled")}}
index 17472b6bde93439703cd5e5c4d68ef5e8b28a905..212379fce344616edc0fb1960bc6d51478df7669 100644 (file)
@@ -283,6 +283,22 @@ def make_unicode(s):
             return str(s).decode('utf8')
 
 
+def split_semicolon(s):
+    parts = s.split(';')
+    merged_parts = []
+    for p in parts:
+        if merged_parts and merged_parts[-1][-1] == '\\':
+            merged_parts[-1] = merged_parts[-1][:-1] + ';' + p
+            
+        else:
+            merged_parts.append(p)
+    
+    if not merged_parts:
+        return []
+
+    return [p.strip() for p in merged_parts]
+
+
 def get_disk_usage(path):
     logging.debug('getting disk usage for path %(path)s...' % {
             'path': path})