| 25 | } |
| 26 | |
| 27 | static String validateSQLiteDatabasePath(const String & path, const String & user_files_path, bool need_check, bool throw_on_error) |
| 28 | { |
| 29 | String absolute_path = fs::absolute(path).lexically_normal(); |
| 30 | |
| 31 | if (fs::path(path).is_relative()) |
| 32 | absolute_path = fs::absolute(fs::path(user_files_path) / path).lexically_normal(); |
| 33 | |
| 34 | String absolute_user_files_path = fs::absolute(user_files_path).lexically_normal(); |
| 35 | |
| 36 | if (need_check && !absolute_path.starts_with(absolute_user_files_path)) |
| 37 | { |
| 38 | processSQLiteError(fmt::format("SQLite database file path '{}' must be inside 'user_files' directory", path), throw_on_error); |
| 39 | return ""; |
| 40 | } |
| 41 | return absolute_path; |
| 42 | } |
| 43 | |
| 44 | SQLitePtr openSQLiteDB(const String & path, ContextPtr context, bool throw_on_error) |
| 45 | { |
no test coverage detected