From 3033e428aba1418e7797fb987c1280c6db67c305 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Tue, 14 Dec 2010 00:32:39 +0000 Subject: - Improve handling of table names containing backslashes --- Source/SPTableData.m | 2 ++ Source/SPXMLExporter.m | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/SPTableData.m b/Source/SPTableData.m index 404395b9..28717864 100644 --- a/Source/SPTableData.m +++ b/Source/SPTableData.m @@ -944,6 +944,7 @@ // Run the status query and retrieve as a dictionary. NSMutableString *escapedTableName = [NSMutableString stringWithString:[tableListInstance tableName]]; + [escapedTableName replaceOccurrencesOfString:@"\\" withString:@"\\\\" options:0 range:NSMakeRange(0, [escapedTableName length])]; [escapedTableName replaceOccurrencesOfString:@"'" withString:@"\\\'" options:0 range:NSMakeRange(0, [escapedTableName length])]; MCPResult *tableStatusResult = nil; @@ -964,6 +965,7 @@ tableStatusResult = [mySQLConnection queryString:[NSString stringWithFormat:@"SELECT * FROM information_schema.VIEWS AS r WHERE r.TABLE_NAME = '%@' AND r.TABLE_SCHEMA = '%@'", escapedTableName, escapedDatabaseName]]; } else if ([tableListInstance tableType] == SPTableTypeTable) { + [escapedTableName replaceOccurrencesOfRegex:@"\\\\(?=\\Z|[^\'])" withString:@"\\\\\\\\"]; tableStatusResult = [mySQLConnection queryString:[NSString stringWithFormat:@"SHOW TABLE STATUS LIKE '%@'", escapedTableName ]]; [tableStatusResult setReturnDataAsStrings:YES]; } diff --git a/Source/SPXMLExporter.m b/Source/SPXMLExporter.m index 962d5a53..57977be0 100644 --- a/Source/SPXMLExporter.m +++ b/Source/SPXMLExporter.m @@ -113,7 +113,9 @@ if (([self xmlFormat] == SPXMLExportMySQLFormat) && [self xmlOutputIncludeStructure]) { structureResult = [connection queryString:[NSString stringWithFormat:@"SHOW COLUMNS FROM %@", [[self xmlTableName] backtickQuotedString]]]; - statusResult = [connection queryString:[NSString stringWithFormat:@"SHOW TABLE STATUS LIKE %@", [[self xmlTableName] tickQuotedString]]]; + NSMutableString *escapedTableName = [NSMutableString stringWithString:[[self xmlTableName] tickQuotedString]]; + [escapedTableName replaceOccurrencesOfString:@"\\" withString:@"\\\\\\\\" options:0 range:NSMakeRange(0, [escapedTableName length])]; + statusResult = [connection queryString:[NSString stringWithFormat:@"SHOW TABLE STATUS LIKE %@", escapedTableName]]; if ([structureResult numOfRows] && [statusResult numOfRows]) { -- cgit v1.2.3