~dpm/qreator/snap

« back to all changes in this revision

Viewing changes to qreator/qrcodes/QRCodeWifiGtk.py

  • Committer: Stefan Schwarzburg
  • Date: 2013-08-06 06:40:48 UTC
  • mto: This revision was merged to the branch mainline in revision 177.
  • Revision ID: stefan.schwarzburg@gmail.com-20130806064048-g0rhe9winmu4yrbr
added an escape function to the wifi datatype to fix bug 1208033

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
from gi.repository import Gtk, NetworkManager, NMClient, GLib, GdkPixbuf
21
21
 
22
22
 
 
23
def _escape(st):
 
24
        """Replace problematic characters with the escaped versions.
 
25
 
 
26
        Note that the backslash must be the first character to replace"""
 
27
        esc_string = st
 
28
        for c in ["\\", ",", ":", ";"]:
 
29
            esc_string = esc_string.replace(c, "\\" + c)
 
30
        return esc_string
 
31
    
 
32
 
23
33
class QRCodeWifiGtk(object):
24
34
    def __init__(self, qr_code_update_func):
25
35
        self.qr_code_update_func = qr_code_update_func
94
104
        if not security or ssid == '' or password == '':
95
105
            return
96
106
 
97
 
        wifi_qr_code = 'WIFI:T:{0};S:{1};P:{2};;'.format(security, ssid,
98
 
                                                         password)
 
107
        wifi_qr_code = 'WIFI:T:{0};S:{1};P:{2};;'.format(_escape(security), _escape(ssid),
 
108
                                                         _escape(password))
99
109
        self.qr_code_update_func(wifi_qr_code)
100
110
 
101
111
    def on_comboboxtextSecurity_changed(self, widget, data=None):