[Groonga-commit] groonga/groonga-command-parser at 7b6506a [master] Add a error check for garbage after load

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Oct 31 12:46:17 JST 2017


Kouhei Sutou	2017-10-31 12:46:17 +0900 (Tue, 31 Oct 2017)

  New Revision: 7b6506a219d43ddc72919a23e119bb800d04a6e7
  https://github.com/groonga/groonga-command-parser/commit/7b6506a219d43ddc72919a23e119bb800d04a6e7

  Message:
    Add a error check for garbage after load

  Modified files:
    lib/groonga/command/parser.rb
    test/test-parser.rb

  Modified: lib/groonga/command/parser.rb (+5 -0)
===================================================================
--- lib/groonga/command/parser.rb    2017-10-31 12:31:25 +0900 (f1d1fe3)
+++ lib/groonga/command/parser.rb    2017-10-31 12:46:17 +0900 (776f4d7)
@@ -316,6 +316,11 @@ module Groonga
       def parse_command_line(command_line)
         splitter = CommandLineSplitter.new(command_line)
         name, *arguments = splitter.split
+        if name.nil?
+          raise Error.new("invalid command name",
+                          command_line,
+                          "")
+        end
         pair_arguments = {}
         ordered_arguments = []
         until arguments.empty?

  Modified: test/test-parser.rb (+15 -0)
===================================================================
--- test/test-parser.rb    2017-10-31 12:31:25 +0900 (25726fe)
+++ test/test-parser.rb    2017-10-31 12:46:17 +0900 (8f74870)
@@ -492,6 +492,21 @@ XXX
               JSON
             end
           end
+
+          def test_garbage_after_json
+            message = "invalid command name"
+            before = "\""
+            after = ""
+            error = Groonga::Command::Parser::Error.new(message, before, after)
+            assert_raise(error) do
+              @parser << <<-JSON
+load --table Users
+[
+{"_key": "alice", "name": "Alice"}
+]"
+              JSON
+            end
+          end
         end
       end
 
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20171031/22139e9e/attachment.htm 



More information about the Groonga-commit mailing list
Back to archive index