You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by br...@apache.org on 2020/08/19 15:35:21 UTC

[cassandra] branch trunk updated: Fix unicode characters in cqlsh input

This is an automated email from the ASF dual-hosted git repository.

brandonwilliams pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 8abbfc1  Fix unicode characters in cqlsh input
8abbfc1 is described below

commit 8abbfc1fc5244e5686de0d04a1f71a004204030f
Author: Ekaterina Dimitrova <ek...@datastax.com>
AuthorDate: Tue Aug 4 14:30:28 2020 -0400

    Fix unicode characters in cqlsh input
    
    Patch by Ekaterina Dimitrova, reviewed by dcapwell and brandonwilliams
    for CASSANDRA-15990
---
 CHANGES.txt  |  2 +-
 bin/cqlsh.py | 13 +++++++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index d617dec..3d9a9eb 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 4.0-beta2
+ * Fix unicode chars error input (CASSANDRA-15990)
  * Improved testability for CacheMetrics and ChunkCacheMetrics (CASSANDRA-15788)
  * Handle errors in StreamSession#prepare (CASSANDRA-15852)
  * FQL replay should have options to ignore DDL statements (CASSANDRA-16039)
@@ -23,7 +24,6 @@ Merged from 3.0:
 Merged from 2.2:
  * Fix CQL parsing of collections when the column type is reversed (CASSANDRA-15814)
 
-
 4.0-beta1
  * Remove BackPressureStrategy (CASSANDRA-15375)
  * Improve messaging on indexing frozen collections (CASSANDRA-15908)
diff --git a/bin/cqlsh.py b/bin/cqlsh.py
index db13bb8..1ef0c91 100644
--- a/bin/cqlsh.py
+++ b/bin/cqlsh.py
@@ -352,6 +352,10 @@ class DecodeError(Exception):
         return '<%s %s>' % (self.__class__.__name__, self.message())
 
 
+def maybe_ensure_text(val):
+    return ensure_text(val) if val else val
+
+
 class FormatError(DecodeError):
     verb = 'format'
 
@@ -414,7 +418,7 @@ def insert_driver_hooks():
 
 
 class Shell(cmd.Cmd):
-    custom_prompt = os.getenv('CQLSH_PROMPT', '')
+    custom_prompt = ensure_text(os.getenv('CQLSH_PROMPT', ''))
     if custom_prompt != '':
         custom_prompt += "\n"
     default_prompt = custom_prompt + "cqlsh> "
@@ -859,7 +863,7 @@ class Shell(cmd.Cmd):
 
     def get_input_line(self, prompt=''):
         if self.tty:
-            self.lastcmd = input(prompt)
+            self.lastcmd = input(ensure_str(prompt))
             line = ensure_text(self.lastcmd) + '\n'
         else:
             self.lastcmd = ensure_text(self.stdin.readline())
@@ -2139,6 +2143,11 @@ def read_options(cmdlineargs, environment):
     optvalues.execute = None
 
     (options, arguments) = parser.parse_args(cmdlineargs, values=optvalues)
+    # Make sure some user values read from the command line are in unicode
+    options.execute = maybe_ensure_text(options.execute)
+    options.username = maybe_ensure_text(options.username)
+    options.password = maybe_ensure_text(options.password)
+    options.keyspace = maybe_ensure_text(options.keyspace)
 
     hostname = option_with_default(configs.get, 'connection', 'hostname', DEFAULT_HOST)
     port = option_with_default(configs.get, 'connection', 'port', DEFAULT_PORT)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org