[Groonga-commit] ranguba/chupa-text-decomposer-html at 3e56778 [master] Prevent infinite loop

アーカイブの一覧に戻る

Kouhei Sutou null+****@clear*****
Mon Jul 10 17:20:37 JST 2017


Kouhei Sutou	2017-07-10 17:20:37 +0900 (Mon, 10 Jul 2017)

  New Revision: 3e567788bb86b4f5b19c829d25025e983b0452b1
  https://github.com/ranguba/chupa-text-decomposer-html/commit/3e567788bb86b4f5b19c829d25025e983b0452b1

  Message:
    Prevent infinite loop

  Modified files:
    lib/chupa-text/decomposers/html.rb
    test/test-html.rb

  Modified: lib/chupa-text/decomposers/html.rb (+4 -0)
===================================================================
--- lib/chupa-text/decomposers/html.rb    2017-07-10 11:45:42 +0900 (215c1c6)
+++ lib/chupa-text/decomposers/html.rb    2017-07-10 17:20:37 +0900 (d21b093)
@@ -28,6 +28,10 @@ module ChupaText
         "application/xhtml+xml",
       ]
       def target?(data)
+        (data["source-mime-types"] || []).each do |source_mime_type|
+          return false if TARGET_MIME_TYPES.include?(source_mime_type)
+        end
+
         return true if TARGET_EXTENSIONS.include?(data.extension)
         return true if TARGET_MIME_TYPES.include?(data.mime_type)
 

  Modified: test/test-html.rb (+24 -0)
===================================================================
--- test/test-html.rb    2017-07-10 11:45:42 +0900 (248116d)
+++ test/test-html.rb    2017-07-10 17:20:37 +0900 (3e036ff)
@@ -28,6 +28,30 @@ class TestHTML < Test::Unit::TestCase
   end
 
   sub_test_case("target?") do
+    sub_test_case("source-mime-type") do
+      def create_data(uri, mime_type)
+        data = ChupaText::Data.new
+        data.body = ""
+        data.uri = uri
+        data["source-mime-types"] = [mime_type]
+        data
+      end
+
+      def test_text_html
+        data = create_data("index.html", "text/html")
+        assert do
+          not****@decom*****?(data)
+        end
+      end
+
+      def test_application_xhtml_xml
+        data = create_data("index.html", "application/xhtml+xml")
+        assert do
+          not****@decom*****?(data)
+        end
+      end
+    end
+
     sub_test_case("extension") do
       def create_data(uri)
         data = ChupaText::Data.new
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る