From a1bd87098ccca2e1125e99a1c334452de41f24dd Mon Sep 17 00:00:00 2001 From: Alex Ling Date: Thu, 28 Jan 2021 12:41:51 +0000 Subject: [PATCH] Escape single quotes in migration 8 --- migration/relative_path.8.cr | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/migration/relative_path.8.cr b/migration/relative_path.8.cr index cf22080..ec58ee6 100644 --- a/migration/relative_path.8.cr +++ b/migration/relative_path.8.cr @@ -1,7 +1,9 @@ class RelativePath < MG::Base def up : String base = Config.current.library_path - base = base[...-1] if base.ends_with? "/" + # Escape single quotes in case the path contains them, and remove the + # trailing slash (this is a mistake, fixed in DB version 10) + base = base.gsub("'", "''").rstrip "/" <<-SQL -- update the path column in ids to relative paths @@ -16,7 +18,7 @@ class RelativePath < MG::Base def down : String base = Config.current.library_path - base = base[...-1] if base.ends_with? "/" + base = base.gsub("'", "''").rstrip "/" <<-SQL -- update the path column in ids to absolute paths