Project

General

Profile

Bug #14626

Updated by Sebastian Wagner over 4 years ago

@CephString.__init__@ 
 CephString.__init__ does this: 

 <pre><code class="python"> 
         self.goodset = frozenset( 
             [c for c in printable if re.match(goodchars, c)] 
         ) 
 </code></pre> 

 ('printable' is a python constant that is printable ascii chars) 

 Multiple interlocked issues here: 
  1. If we really forbid non-ascii, the check belongs in the mon where it can't be circumvented, not in the python bindings. 
  2. We shouldn't forbid non-ascii characters.    client.björn should be valid (even domain names support unicode these days) 
  3. If someone submits non-ascii input, currently they get a UnicodeEncodeError like this: 
 <pre> 
 ceph auth get-or-create "client.Björn" 
 *** DEVELOPER MODE: setting PATH, PYTHONPATH and LD_LIBRARY_PATH *** 
 2016-02-03 11:50:45.769856 7fa828d76700    0 lockdep start 
 2016-02-03 11:50:45.770757 7fa828d76700 -1 WARNING: the following dangerous and experimental features are enabled: * 
 2016-02-03 11:50:45.786774 7fa828d76700 -1 WARNING: the following dangerous and experimental features are enabled: * 
 Traceback (most recent call last): 
   File "./ceph", line 939, in <module> 
     retval = main() 
   File "./ceph", line 873, in main 
     sigdict, inbuf, verbose) 
   File "./ceph", line 407, in new_style_command 
     valid_dict = validate_command(sigdict, cmdargs, verbose) 
   File "/home/john/ceph/src/pybind/ceph_argparse.py", line 958, in validate_command 
     matched = matchnum(args, sig, partial=True) 
   File "/home/john/ceph/src/pybind/ceph_argparse.py", line 766, in matchnum 
     validate_one(word, desc, partial and (len(words) == 0)) 
   File "/home/john/ceph/src/pybind/ceph_argparse.py", line 737, in validate_one 
     desc.instance.valid(word, partial) 
   File "/home/john/ceph/src/pybind/ceph_argparse.py", line 211, in valid 
     format(''.join(sset - self.goodset), s)) 
 UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in position 0: ordinal not in range(128) 
 </pre> 

 ...because the string formatting for the exception doesn't take account of the possibility that *its* arguments might be non-ascii. 

Back