[Groonga-commit] droonga/droonga-client-ruby at 0406502 [master] Validate command name (workaround)

Back to archive index

YUKI Hiroshi null+****@clear*****
Wed Apr 15 16:25:49 JST 2015


YUKI Hiroshi	2015-04-15 16:25:49 +0900 (Wed, 15 Apr 2015)

  New Revision: 0406502e90f62e54e7c87c7794a43e8eaf73d266
  https://github.com/droonga/droonga-client-ruby/commit/0406502e90f62e54e7c87c7794a43e8eaf73d266

  Message:
    Validate command name (workaround)

  Modified files:
    bin/droonga-groonga

  Modified: bin/droonga-groonga (+13 -0)
===================================================================
--- bin/droonga-groonga    2015-04-15 16:23:14 +0900 (0421b56)
+++ bin/droonga-groonga    2015-04-15 16:25:49 +0900 (422b9ab)
@@ -22,6 +22,12 @@ require "droonga/command/base"
 module Droonga
   module Command
     class Groonga < Base
+      class InvalidCommandName < StandardError
+      end
+
+      class MissingCommandName < StandardError
+      end
+
       def run
         parse_options do |option|
           option.banner("Usage: droonga-groonga [groonga-command-name] [options]\n" +
@@ -34,6 +40,8 @@ module Droonga
         end
 
         groonga_command_name = ARGV.shift
+        assert_valid_command(groonga_command_name)
+
         groonga_message = {
           "dataset" => @options[:dataset],
           "type" => groonga_command_name,
@@ -53,6 +61,11 @@ module Droonga
       end
 
       private
+      def assert_valid_command(command)
+        raise InvalidCommandName.new(command) if /\A--.+\z/ =~ command
+        raise MissingCommandName.new if command.nil?
+      end
+
       def build_params(argv)
         params = {}
         option_name = nil
-------------- next part --------------
HTML����������������������������...
다운로드 



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