]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/database/SQLFileManager.java
Merge "Update notes about password security"
[gigi.git] / src / org / cacert / gigi / database / SQLFileManager.java
index 9aaebfae883c5ead9ff40d14a29846dac7f10095..9f563dbb476062c175928243c16b5bdb5a8326a4 100644 (file)
@@ -27,20 +27,22 @@ public class SQLFileManager {
 
     public static void addFile(Statement stmt, InputStream f, ImportType type) throws IOException, SQLException {
         String sql = readFile(f);
-        sql = sql.replaceAll("--[^\n]+\n", "\n");
+        sql = sql.replaceAll("--[^\n]*\n", "\n");
+        sql = sql.replaceAll("#[^\n]*\n", "\n");
         String[] stmts = sql.split(";");
-        Pattern p = Pattern.compile("\\s*DROP TABLE IF EXISTS `([^`]+)`");
+        Pattern p = Pattern.compile("\\s*DROP TABLE IF EXISTS \"([^\"]+)\"");
         for (String string : stmts) {
             Matcher m = p.matcher(string);
             string = string.trim();
             if (string.equals("")) {
                 continue;
             }
-            if ((string.contains("profiles") || string.contains("cacerts")) && type != ImportType.PRODUCTION) {
+            if ((string.contains("profiles") || string.contains("cacerts") || string.contains("cats_type") || string.contains("countryIsoCode")) && type == ImportType.TRUNCATE) {
                 continue;
             }
+            string = DatabaseConnection.preprocessQuery(string);
             if (m.matches() && type == ImportType.TRUNCATE) {
-                String sql2 = "TRUNCATE `" + m.group(1) + "`";
+                String sql2 = "DELETE FROM \"" + m.group(1) + "\"";
                 stmt.addBatch(sql2);
                 continue;
             }