Package xmpp :: Module jep0106
[hide private]
[frames] | no frames]

Source Code for Module xmpp.jep0106

 1   
 2  # JID Escaping XEP-0106 for the xmpppy based transports written by Norman Rasmussen 
 3   
 4  """This file is the XEP-0106 commands. 
 5   
 6  Implemented commands as follows: 
 7   
 8  4.2 Encode : Encoding Transformation 
 9  4.3 Decode : Decoding Transformation 
10   
11   
12  """ 
13   
14  xep0106mapping = [ 
15          [' ' ,'20'], 
16          ['"' ,'22'], 
17          ['&' ,'26'], 
18          ['\'','27'], 
19          ['/' ,'2f'], 
20          [':' ,'3a'], 
21          ['<' ,'3c'], 
22          ['>' ,'3e'], 
23          ['@' ,'40']] 
24   
25 -def JIDEncode(str):
26 str = str.replace('\\5c', '\\5c5c') 27 for each in xep0106mapping: 28 str = str.replace('\\' + each[1], '\\5c' + each[1]) 29 for each in xep0106mapping: 30 str = str.replace(each[0], '\\' + each[1]) 31 return str
32
33 -def JIDDecode(str):
34 for each in xep0106mapping: 35 str = str.replace('\\' + each[1], each[0]) 36 return str.replace('\\5c', '\\')
37