File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,24 @@ public static string UrlDecode(this string input)
49
49
/// </summary>
50
50
public static string UrlEncode ( this string input )
51
51
{
52
- return Uri . EscapeDataString ( input ) ;
52
+ const int maxLength = 32766 ;
53
+ if ( input == null )
54
+ throw new ArgumentNullException ( "input" ) ;
55
+
56
+ if ( input . Length <= maxLength )
57
+ return Uri . EscapeDataString ( input ) ;
58
+
59
+ StringBuilder sb = new StringBuilder ( input . Length * 2 ) ;
60
+ int index = 0 ;
61
+ while ( index < input . Length )
62
+ {
63
+ int length = Math . Min ( input . Length - index , maxLength ) ;
64
+ string subString = input . Substring ( index , length ) ;
65
+ sb . Append ( Uri . EscapeDataString ( subString ) ) ;
66
+ index += subString . Length ;
67
+ }
68
+
69
+ return sb . ToString ( ) ;
53
70
}
54
71
55
72
public static string HtmlDecode ( this string input )
You can’t perform that action at this time.
0 commit comments