From 86d2477f978735b63eaa7ca2f0c7c8e3b8770c12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Wed, 28 Aug 2013 23:21:46 +0200 Subject: [PATCH] properly escape backslashes --- db/migrate/20130828192526_fix_optimized_images_urls.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/migrate/20130828192526_fix_optimized_images_urls.rb b/db/migrate/20130828192526_fix_optimized_images_urls.rb index 4e19bb9076f..c605b7b74ed 100644 --- a/db/migrate/20130828192526_fix_optimized_images_urls.rb +++ b/db/migrate/20130828192526_fix_optimized_images_urls.rb @@ -2,15 +2,15 @@ class FixOptimizedImagesUrls < ActiveRecord::Migration def up # `AddUrlToOptimizedImages` was wrongly computing the URLs. This fixes it! execute "UPDATE optimized_images - SET url = substring(oi.url from '^\/uploads\/[^/]+\/_optimized/[0-9a-f]{3}/[0-9a-f]{3}/[0-9a-f]{11}') + SET url = substring(oi.url from '^\\/uploads\\/[^/]+\\/_optimized\\/[0-9a-f]{3}\\/[0-9a-f]{3}\\/[0-9a-f]{11}') || '_' || oi.width || 'x' || oi.height - || substring(oi.url from '\.\w{3,4}$') + || substring(oi.url from '\\.\\w{3,4}$') FROM optimized_images oi WHERE optimized_images.id = oi.id - AND oi.url ~ '^\/uploads\/[^/]+\/_optimized\/[0-9a-f]{3}/[0-9a-f]{3}/[0-9a-f]{11}\.';" + AND oi.url ~ '^\\/uploads\\/[^/]+\\/_optimized\\/[0-9a-f]{3}\\/[0-9a-f]{3}\\/[0-9a-f]{11}\\.';" end def down