From 9d2b587aa64f32478d61bdb2dbe0555dbf4a6849 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Thu, 10 Oct 2013 15:23:52 +0000 Subject: [PATCH] Fix oops in html-thread migration script --- .../streams/core/d51f303a-dad45ca2.patch.sql | 163 +++++++++++------- 1 file changed, 100 insertions(+), 63 deletions(-) diff --git a/include/upgrader/streams/core/d51f303a-dad45ca2.patch.sql b/include/upgrader/streams/core/d51f303a-dad45ca2.patch.sql index 6f2727600..94b8f8aa7 100644 --- a/include/upgrader/streams/core/d51f303a-dad45ca2.patch.sql +++ b/include/upgrader/streams/core/d51f303a-dad45ca2.patch.sql @@ -45,92 +45,129 @@ CREATE TABLE `%TABLE_PREFIX%draft` ( -- Migrate email templates to HTML UPDATE `%TABLE_PREFIX%email_template` - SET `body` = REPLACE('\n', '<br/>', - REPLACE('<', '<', - REPLACE('>', '>', - REPLACE('&', '&', `body`)))); + SET `body` = REPLACE( REPLACE( REPLACE( REPLACE( + `body`, + '<', '<'), + '>', '>'), + '\n', '<br/>'), + '&', '&'); -- Migrate notes to HTML UPDATE `%TABLE_PREFIX%api_key` - SET `notes` = REPLACE('\n', '<br/>', - REPLACE('<', '<', - REPLACE('>', '>', - REPLACE('&', '&', `notes`)))); + SET `notes` = REPLACE( REPLACE( REPLACE( REPLACE( + `notes`, + '<', '<'), + '>', '>'), + '\n', '<br/>'), + '&', '&'); UPDATE `%TABLE_PREFIX%email` - SET `notes` = REPLACE('\n', '<br/>', - REPLACE('<', '<', - REPLACE('>', '>', - REPLACE('&', '&', `notes`)))); + SET `notes` = REPLACE( REPLACE( REPLACE( REPLACE( + `notes`, + '<', '<'), + '>', '>'), + '\n', '<br/>'), + '&', '&'); UPDATE `%TABLE_PREFIX%email_template_group` - SET `notes` = REPLACE('\n', '<br/>', - REPLACE('<', '<', - REPLACE('>', '>', - REPLACE('&', '&', `notes`)))); + SET `notes` = REPLACE( REPLACE( REPLACE( REPLACE( + `notes`, + '<', '<'), + '>', '>'), + '\n', '<br/>'), + '&', '&'); UPDATE `%TABLE_PREFIX%faq` - SET `notes` = REPLACE('\n', '<br/>', - REPLACE('<', '<', - REPLACE('>', '>', - REPLACE('&', '&', `notes`)))); + SET `notes` = REPLACE( REPLACE( REPLACE( REPLACE( + `notes`, + '<', '<'), + '>', '>'), + '\n', '<br/>'), + '&', '&'); UPDATE `%TABLE_PREFIX%faq_category` - SET `notes` = REPLACE('\n', '<br/>', - REPLACE('<', '<', - REPLACE('>', '>', - REPLACE('&', '&', `notes`)))); + SET `notes` = REPLACE( REPLACE( REPLACE( REPLACE( + `notes`, + '<', '<'), + '>', '>'), + '\n', '<br/>'), + '&', '&'); UPDATE `%TABLE_PREFIX%filter` - SET `notes` = REPLACE('\n', '<br/>', - REPLACE('<', '<', - REPLACE('>', '>', - REPLACE('&', '&', `notes`)))); + SET `notes` = REPLACE( REPLACE( REPLACE( REPLACE( + `notes`, + '<', '<'), + '>', '>'), + '\n', '<br/>'), + '&', '&'); UPDATE `%TABLE_PREFIX%groups` - SET `notes` = REPLACE('\n', '<br/>', - REPLACE('<', '<', - REPLACE('>', '>', - REPLACE('&', '&', `notes`)))); + SET `notes` = REPLACE( REPLACE( REPLACE( REPLACE( + `notes`, + '<', '<'), + '>', '>'), + '\n', '<br/>'), + '&', '&'); UPDATE `%TABLE_PREFIX%help_topic` - SET `notes` = REPLACE('\n', '<br/>', - REPLACE('<', '<', - REPLACE('>', '>', - REPLACE('&', '&', `notes`)))); + SET `notes` = REPLACE( REPLACE( REPLACE( REPLACE( + `notes`, + '<', '<'), + '>', '>'), + '\n', '<br/>'), + '&', '&'); UPDATE `%TABLE_PREFIX%page` - SET `notes` = REPLACE('\n', '<br/>', - REPLACE('<', '<', - REPLACE('>', '>', - REPLACE('&', '&', `notes`)))); + SET `notes` = REPLACE( REPLACE( REPLACE( REPLACE( + `notes`, + '<', '<'), + '>', '>'), + '\n', '<br/>'), + '&', '&'); UPDATE `%TABLE_PREFIX%sla` - SET `notes` = REPLACE('\n', '<br/>', - REPLACE('<', '<', - REPLACE('>', '>', - REPLACE('&', '&', `notes`)))); + SET `notes` = REPLACE( REPLACE( REPLACE( REPLACE( + `notes`, + '<', '<'), + '>', '>'), + '\n', '<br/>'), + '&', '&'); UPDATE `%TABLE_PREFIX%staff` - SET `notes` = REPLACE('\n', '<br/>', - REPLACE('<', '<', - REPLACE('>', '>', - REPLACE('&', '&', `notes`)))); + SET `notes` = REPLACE( REPLACE( REPLACE( REPLACE( + `notes`, + '<', '<'), + '>', '>'), + '\n', '<br/>'), + '&', '&'); UPDATE `%TABLE_PREFIX%team` - SET `notes` = REPLACE('\n', '<br/>', - REPLACE('<', '<', - REPLACE('>', '>', - REPLACE('&', '&', `notes`)))); + SET `notes` = REPLACE( REPLACE( REPLACE( REPLACE( + `notes`, + '<', '<'), + '>', '>'), + '\n', '<br/>'), + '&', '&'); -- Migrate canned responses to HTML UPDATE `%TABLE_PREFIX%canned_response` - SET `notes` = REPLACE('\n', '<br/>', - REPLACE('<', '<', - REPLACE('>', '>', - REPLACE('&', '&', `notes`)))), - `response` = REPLACE('\n', '<br/>', - REPLACE('<', '<', - REPLACE('>', '>', - REPLACE('&', '&', `response`)))); + SET `notes` = REPLACE( REPLACE( REPLACE( REPLACE( + `notes`, + '<', '<'), + '>', '>'), + '\n', '<br/>'), + '&', '&'), + `response` = REPLACE( REPLACE( REPLACE( REPLACE( + `response`, + '<', '<'), + '>', '>'), + '\n', '<br/>'), + '&', '&'); -- Migrate ticket-thread to HTML -- XXX: Migrate & -> & ? -- the problem is that there's a fix in 1.7.1 -- that properly encodes these characters, so encoding & would mean possible -- double encoding. UPDATE `%TABLE_PREFIX%ticket_thread` - SET `body` = REPLACE('\n', '<br/>', - REPLACE('<', '<', - REPLACE('>', '>', `body`))); + SET `body` = REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( + `body`, + '\r', ''), + '\n ', '\n'), + '\n\n\n', '\n\n'), + '\n\n\n', '\n\n'), + '\n\n\n', '\n\n'), + '<', '<'), + '>', '>'), + '\n', '<br/>'); -- Finished with patch UPDATE `%TABLE_PREFIX%config` -- GitLab