File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed
src/MySqlConnector/MySqlClient
tests/MySqlConnector.Tests Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -24,15 +24,14 @@ public static string EscapeString(string value)
24
24
{
25
25
if ( sb == null )
26
26
sb = new StringBuilder ( ) ;
27
- if ( i > last - 1 )
28
- sb . Append ( value , last + 1 , i - last - 1 ) ;
27
+ sb . Append ( value , last + 1 , i - ( last + 1 ) ) ;
29
28
sb . Append ( '\\ ' ) ;
30
29
sb . Append ( value [ i ] ) ;
31
30
last = i ;
32
31
}
33
32
}
34
- if ( sb != null && last < value . Length - 1 )
35
- sb . Append ( value , last + 1 , value . Length - last - 1 ) ;
33
+ if ( sb != null )
34
+ sb . Append ( value , last + 1 , value . Length - ( last + 1 ) ) ;
36
35
37
36
return sb ? . ToString ( ) ?? value ;
38
37
}
Original file line number Diff line number Diff line change @@ -9,11 +9,13 @@ public class MySqlHelperTests
9
9
[ InlineData ( "" , "" ) ]
10
10
[ InlineData ( "test" , "test" ) ]
11
11
[ InlineData ( "\" " , "\\ \" " ) ]
12
- [ InlineData ( "'" , "\\ '" ) ]
13
- [ InlineData ( "\\ " , "\\ \\ " ) ]
12
+ [ InlineData ( @"'" , @"\'" ) ]
13
+ [ InlineData ( @"\" , @"\\" ) ]
14
+ [ InlineData ( @"''" , @"\'\'" ) ]
14
15
[ InlineData ( @"'begin" , @"\'begin" ) ]
15
16
[ InlineData ( @"end'" , @"end\'" ) ]
16
17
[ InlineData ( @"mid'dle" , @"mid\'dle" ) ]
18
+ [ InlineData ( @"doub''led" , @"doub\'\'led" ) ]
17
19
[ InlineData ( @"'a'b'" , @"\'a\'b\'" ) ]
18
20
public void EscapeString ( string input , string expected )
19
21
{
You can’t perform that action at this time.
0 commit comments