Code cleanup, removed API ulr in configuration (people might get confused) and merged a Imgure helper method into the OAuthHelper.cs. Also removed the history menu entry for PhotobucketPlugin (which isn't used yet)

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2028 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-09-13 11:37:58 +00:00
parent 34d2689818
commit 8f90c54729
3 changed files with 41 additions and 80 deletions

View file

@ -209,26 +209,39 @@ namespace GreenshotPlugin.Core {
return result;
}
/// <summary>
/// A wrapper around the EscapeDataString, as the limit is 32766 characters
/// See: http://msdn.microsoft.com/en-us/library/system.uri.escapedatastring%28v=vs.110%29.aspx
/// </summary>
/// <param name="dataString"></param>
/// <returns>escaped data string</returns>
private static StringBuilder EscapeDataStringToStringBuilder(string dataString) {
StringBuilder result = new StringBuilder();
int currentLocation = 0;
while (currentLocation < dataString.Length) {
string process = dataString.Substring(currentLocation, Math.Min(16384, dataString.Length - currentLocation));
result.Append(Uri.EscapeDataString(process));
currentLocation = currentLocation + 16384;
}
return result;
}
/// <summary>
/// This is a different Url Encode implementation since the default .NET one outputs the percent encoding in lower case.
/// While this is not a problem with the percent encoding spec, it is used in upper case throughout OAuth
/// </summary>
/// <param name="value">The value to Url encode</param>
/// <returns>Returns a Url encoded string</returns>
public static string UrlEncode3986(string value) {
StringBuilder result = new StringBuilder();
public static string UrlEncode3986(string text) {
string[] UriRfc3986CharsToEscape = new[] { "!", "*", "'", "(", ")" };
LOG.DebugFormat("Text size {0}", text.Length);
StringBuilder escaped = EscapeDataStringToStringBuilder(text);
foreach (char symbol in value) {
if (unreservedChars.IndexOf(symbol) != -1) {
result.Append(symbol);
} else {
result.Append('%' + String.Format("{0:X2}", (int)symbol));
}
for (int i = 0; i < UriRfc3986CharsToEscape.Length; i++) {
escaped.Replace(UriRfc3986CharsToEscape[i], Uri.HexEscape(UriRfc3986CharsToEscape[i][0]));
}
return result.ToString();
return escaped.ToString();
}
/// <summary>
/// Normalizes the request parameters according to the spec
/// </summary>