Commits

s...@openoffice.org  committed 0ea6b61

fwk158: #i114541# generally ignore erroneous xcs/xcu files during startup (typically from extensions installed pre 3.3)

  • Participants
  • Parent commits ca1b98f

Comments (0)

Files changed (2)

File configmgr/source/components.cxx

     Modifications * modifications)
 {
     OSL_ASSERT(modifications != 0);
+    Partial part(includedPaths, excludedPaths);
     try {
-        Partial part(includedPaths, excludedPaths);
-        parseXcuFile(fileUri, Data::NO_LAYER, data_, &part, modifications, 0);
-    } catch (css::uno::Exception & e) { //TODO: more specific exception catching
+        parseFileLeniently(
+            &parseXcuFile, fileUri, Data::NO_LAYER, data_, &part, modifications,
+            0);
+    } catch (css::container::NoSuchElementException & e) {
         OSL_TRACE(
-            "configmgr error inserting %s: %s",
+            "configmgr error inserting non-existing %s: %s",
             rtl::OUStringToOString(fileUri, RTL_TEXTENCODING_UTF8).getStr(),
             rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
     }
                     "com.sun.star.comp.deployment.configuration."
                     "PackageRegistryBackend/configmgr.ini"))),
         true);
-    try {
-        parseModificationLayer();
-    } catch (css::uno::Exception & e) { //TODO: more specific exception catching
-        // Silently ignore unreadable parts of a corrupted user modification
-        // layer, instead of completely preventing OOo from starting:
-        OSL_TRACE(
-            "configmgr error reading user modification layer: %s",
-            rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
-    }
+    parseModificationLayer();
     RTL_LOGFILE_TRACE_AUTHOR("configmgr", "sb", "end parsing");
 }
 
 Components::~Components() {}
 
+void Components::parseFileLeniently(
+    FileParser * parseFile, rtl::OUString const & url, int layer, Data & data,
+    Partial const * partial, Modifications * modifications,
+    Additions * additions)
+{
+    OSL_ASSERT(parseFile != 0);
+    try {
+        (*parseFile)(url, layer, data, partial, modifications, additions);
+    } catch (css::container::NoSuchElementException &) {
+        throw;
+    } catch (css::uno::Exception & e) { //TODO: more specific exception catching
+        // Silently ignore invalid XML files, instead of completely preventing
+        // OOo from starting:
+        OSL_TRACE(
+            "configmgr error reading %s: %s",
+            rtl::OUStringToOString(url, RTL_TEXTENCODING_UTF8).getStr(),
+            rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
+    }
+}
+
 void Components::parseFiles(
     int layer, rtl::OUString const & extension, FileParser * parseFile,
     rtl::OUString const & url, bool recursive)
                 file.match(extension, file.getLength() - extension.getLength()))
             {
                 try {
-                    (*parseFile)(stat.getFileURL(), layer, data_, 0, 0, 0);
+                    parseFileLeniently(
+                        parseFile, stat.getFileURL(), layer, data_, 0, 0, 0);
                 } catch (css::container::NoSuchElementException & e) {
                     throw css::uno::RuntimeException(
                         (rtl::OUString(
                 adds = data_.addExtensionXcuAdditions(url, layer);
             }
             try {
-                (*parseFile)(url, layer, data_, 0, 0, adds);
+                parseFileLeniently(parseFile, url, layer, data_, 0, 0, adds);
             } catch (css::container::NoSuchElementException & e) {
                 OSL_TRACE(
                     "configmgr file does not exist: %s",
 
 void Components::parseModificationLayer() {
     try {
-        parseXcuFile(getModificationFileUrl(), Data::NO_LAYER, data_, 0, 0, 0);
+        parseFileLeniently(
+            &parseXcuFile, getModificationFileUrl(), Data::NO_LAYER, data_, 0,
+            0, 0);
     } catch (css::container::NoSuchElementException &) {
         OSL_TRACE(
             "configmgr user registrymodifications.xcu does not (yet) exist");

File configmgr/source/components.hxx

 
     ~Components();
 
+    void parseFileLeniently(
+        FileParser * parseFile, rtl::OUString const & url, int layer,
+        Data & data, Partial const * partial, Modifications * modifications,
+        Additions * additions);
+
     void parseFiles(
         int layer, rtl::OUString const & extension, FileParser * parseFile,
         rtl::OUString const & url, bool recursive);