Giter Site home page Giter Site logo

Comments (2)

rubellyte avatar rubellyte commented on August 15, 2024

This does appear to be an actual issue; the regex used for joining quoted arguments together doesn't handle escapes. Let me see if I can quickly fix this.

from starrypy3k.

GermaniumSystem avatar GermaniumSystem commented on August 15, 2024

Thanks for the quick response! I came to the same conclusion and gave shlex a shot. It seems to work really well, but I'm not familiar enough with the project to know if adding it would have unintended consequences.

Here's a diff:

diff --git a/plugins/command_dispatcher.py b/plugins/command_dispatcher.py
index bc356c3..3629ac3 100644
--- a/plugins/command_dispatcher.py
+++ b/plugins/command_dispatcher.py
@@ -13,9 +13,10 @@ Updated for release: kharidiron
 
 import asyncio
 import packets
+import shlex
 
 from base_plugin import BasePlugin
-from utilities import extractor, get_syntax, send_message
+from utilities import get_syntax, send_message
 from data_parser import ChatSent
 from pparser import build_packet
 
@@ -55,8 +56,8 @@ class CommandDispatcher(BasePlugin):
                 full = build_packet(packets.packets['chat_sent'], pkt)
                 yield from connection.client_raw_write(full)
                 return False
-            to_parse = data['parsed']['message'][len(
-                self.plugin_config.command_prefix):].split()
+            to_parse = shlex.split(data['parsed']['message'][len(
+                self.plugin_config.command_prefix):])
 
             try:
                 command = to_parse[0]
@@ -140,8 +141,7 @@ class CommandDispatcher(BasePlugin):
                 General Exception error as a last-resort catch-all.
         """
         try:
-            yield from self.commands[command](extractor(to_parse),
-                                              connection)
+            yield from self.commands[command](to_parse,connection)
         except SyntaxWarning as e:
             self._send_syntax_error(command, e, connection)
         except NameError as e:
diff --git a/utilities.py b/utilities.py
index c0a13e7..bbda05b 100644
--- a/utilities.py
+++ b/utilities.py
@@ -235,18 +235,6 @@ def read_signed_vlq(reader):
         return -((v >> 1) + 1), d
 
 
-def extractor(*args):
-    """
-    Extracts quoted arguments and puts them as a single argument in the
-    passed iterator.
-    """
-    # It's not elegant, but it's the best way to do it as far as I can tell.
-    # My regex-fu isn't strong though, so if someone can come up with a
-    # better way, great.
-    x = re.split(r"(?:([^\"]\S*)|\"(.+?)\")\s*", " ".join(*args))
-    return [x for x in filter(None, x)]
-
-
 @asyncio.coroutine
 def read_packet(reader, direction):
     """

from starrypy3k.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.