W3C test importer breaks svg files.
https://bugs.webkit.org/show_bug.cgi?id=202806

Reviewed by Jonathan Bedard.

The WebKit W3C importer tries to rewrite the xml/html/css files
when importing the tests to rewrite paths and such.

The issue is that to decide if rewrite the file or not uses the
mimetype and the current code was comparing for something like
if "xml" in str(mimetype[0])

But svg files have mimetype "image/svg+xml" so the previous code
was trying to rewrite svg files, breaking them.

This patches changes that code to only rewrite if the mimetype
also contains the "application/" or "text/" string.

It also adds an info log (printed when verbose enabled) to tell
that a file has been rewritten.

* Scripts/webkitpy/w3c/test_importer.py:
(TestImporter.import_tests):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@250992 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index d6535e1..2b42630 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,29 @@
+2019-10-10  Carlos Alberto Lopez Perez  <clopez@igalia.com>
+
+        W3C test importer breaks svg files.
+        https://bugs.webkit.org/show_bug.cgi?id=202806
+
+        Reviewed by Jonathan Bedard.
+
+        The WebKit W3C importer tries to rewrite the xml/html/css files
+        when importing the tests to rewrite paths and such.
+
+        The issue is that to decide if rewrite the file or not uses the
+        mimetype and the current code was comparing for something like
+        if "xml" in str(mimetype[0])
+
+        But svg files have mimetype "image/svg+xml" so the previous code
+        was trying to rewrite svg files, breaking them.
+
+        This patches changes that code to only rewrite if the mimetype
+        also contains the "application/" or "text/" string.
+
+        It also adds an info log (printed when verbose enabled) to tell
+        that a file has been rewritten.
+
+        * Scripts/webkitpy/w3c/test_importer.py:
+        (TestImporter.import_tests):
+
 2019-10-10  Jonathan Bedard  <jbedard@apple.com>
 
         results.webkit.org: Serve correct exit codes when aborting
diff --git a/Tools/Scripts/webkitpy/w3c/test_importer.py b/Tools/Scripts/webkitpy/w3c/test_importer.py
index cf16f3d..051b1bc 100644
--- a/Tools/Scripts/webkitpy/w3c/test_importer.py
+++ b/Tools/Scripts/webkitpy/w3c/test_importer.py
@@ -509,7 +509,9 @@
                 # Only html, xml, or css should be converted
                 # FIXME: Eventually, so should js when support is added for this type of conversion
                 mimetype = mimetypes.guess_type(orig_filepath)
-                if should_rewrite_files and ('html' in str(mimetype[0]) or 'xml' in str(mimetype[0])  or 'css' in str(mimetype[0])):
+                if should_rewrite_files and ('text/' in str(mimetype[0]) or 'application/' in str(mimetype[0])) \
+                                        and ('html' in str(mimetype[0]) or 'xml' in str(mimetype[0])  or 'css' in str(mimetype[0])):
+                    _log.info("Rewriting: %s" % new_filepath)
                     try:
                         converted_file = convert_for_webkit(new_path, filename=orig_filepath, reference_support_info=reference_support_info, host=self.host, convert_test_harness_links=self.should_convert_test_harness_links(subpath), webkit_test_runner_options=self._webkit_test_runner_options(new_filepath))
                     except: