null+****@clear*****
null+****@clear*****
2010年 6月 22日 (火) 15:25:03 JST
Kouhei Sutou 2010-06-22 06:25:03 +0000 (Tue, 22 Jun 2010) New Revision: a2790fde685ccb480214342ba6808e188752fe5e Log: work long path name HTTP request test. Modified files: lib/proc.c test/unit/http/test-invalid-http.rb Modified: lib/proc.c (+7 -0) =================================================================== --- lib/proc.c 2010-06-22 05:42:57 +0000 (d784f19) +++ lib/proc.c 2010-06-22 06:25:03 +0000 (0464bf3) @@ -964,6 +964,13 @@ proc_missing(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data) path + grn_admin_html_path_len + 1, PATH_MAX - grn_admin_html_path_len - 1); grn_bulk_put_from_file(ctx, outbuf, path); + } else { + uint32_t abbrlen = 32; + ERR(GRN_INVALID_ARGUMENT, + "too long path name: <%s%c%.*s...> %u(%u)", + grn_admin_html_path, PATH_SEPARATOR[0], + abbrlen < plen ? abbrlen : plen, GRN_TEXT_VALUE(VAR(0)), + plen + grn_admin_html_path_len, PATH_MAX); } return NULL; } Modified: test/unit/http/test-invalid-http.rb (+12 -1) =================================================================== --- test/unit/http/test-invalid-http.rb 2010-06-22 05:42:57 +0000 (db5efaa) +++ test/unit/http/test-invalid-http.rb 2010-06-22 06:25:03 +0000 (7764dd8) @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2009 Kouhei Sutou <kou****@clear*****> +# Copyright (C) 2009-2010 Kouhei Sutou <kou****@clear*****> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -82,6 +82,17 @@ class InvalidHTTPTest < Test::Unit::TestCase def test_long_path response = get("/0123456789" * 10000) assert_equal("500", response.code) + assert_response([[Result::INVALID_ARGUMENT, + 0.0, + 0.0, + "too long path name: <PATH...> LENGTH(MAX_LENGTH)", + nil]], + response, :content_type => "application/json") do |_response| + message = _response[0][3] + message.gsub!(/<(.+?)\.\.\.>/, '<PATH...>') + message.gsub!(/(\d+)\((\d+)\)/, 'LENGTH(MAX_LENGTH)') + _response + end end def test_long_query