From 1468c0ba048c4cc701ec9b5dec78a8bb1714fcc6 Mon Sep 17 00:00:00 2001 From: ttp Date: Sat, 9 May 2009 02:02:37 +0900 Subject: [PATCH] =?utf8?q?na-get-lib,NaGet.Util.UrlDecode=E3=82=92?= =?utf8?q?=E5=89=8A=E9=99=A4=E3=80=82=EF=BC=88System.Web.HttpUtilities.Url?= =?utf8?q?Decode=E3=81=AE=E5=88=A9=E7=94=A8=E3=81=A8=E3=81=99=E3=82=8B?= =?utf8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- na-get-lib/NaGet/Utils.cs | 65 +------------------------------------------- na-get-lib/na-get-lib.csproj | 1 + 2 files changed, 2 insertions(+), 64 deletions(-) diff --git a/na-get-lib/NaGet/Utils.cs b/na-get-lib/NaGet/Utils.cs index 87b2736..1d71ba5 100644 --- a/na-get-lib/NaGet/Utils.cs +++ b/na-get-lib/NaGet/Utils.cs @@ -154,7 +154,7 @@ namespace NaGet /// 対象のurl public static string Url2filename(string url) { - string filename = Path.GetFileName(UrlDecode(url, Encoding.UTF8)); + string filename = Path.GetFileName(System.Web.HttpUtility.UrlDecode(url, Encoding.UTF8)); int pos; if ((pos = filename.IndexOfAny(Path.GetInvalidFileNameChars())) >= 0) { @@ -170,69 +170,6 @@ namespace NaGet } /// - /// URLのデコードを行う - /// - /// 対象のurl文字列 - /// デコードの処理に使う文字コード - public static string UrlDecode(string s, Encoding e) - { - // mono の System.Net.HttpUtility より作成 - - if (null == s) - return null; - - if (s.IndexOf ('%') == -1 && s.IndexOf ('+') == -1) - return s; - - if (e == null) - e = Encoding.GetEncoding (28591); - - StringBuilder output = new StringBuilder (); - long len = s.Length; - NumberStyles hexa = NumberStyles.HexNumber; - MemoryStream bytes = new MemoryStream (); - - for (int i = 0; i < len; i++) { - if (s [i] == '%' && i + 2 < len) { - if (s [i + 1] == 'u' && i + 5 < len) { - if (bytes.Length > 0) { - //output.Append (GetChars (bytes, e)); - output.Append(e.GetChars(bytes.GetBuffer(), 0, (int) bytes.Length)); - bytes.SetLength (0); - } - - output.Append ((char) int.Parse(s.Substring (i + 2, 4), hexa)); - i += 5; - } else { - bytes.WriteByte ((byte) int.Parse(s.Substring (i + 1, 2), hexa)); - i += 2; - } - continue; - } - - if (bytes.Length > 0) { - //output.Append (GetChars (bytes, e)); - output.Append(e.GetChars(bytes.GetBuffer(), 0, (int) bytes.Length)); - bytes.SetLength (0); - } - - if (s [i] == '+') { - output.Append (' '); - } else { - output.Append (s [i]); - } - } - - if (bytes.Length > 0) { - //output.Append (GetChars (bytes, e)); - output.Append(e.GetChars(bytes.GetBuffer(), 0, (int) bytes.Length)); - } - - bytes = null; - return output.ToString (); - } - - /// /// 再帰的にファイルの属性を指定します。強制的にフォルダの再帰削除の前に読み込み専用属性を消すのに使います。 /// /// 設定するフォルダ diff --git a/na-get-lib/na-get-lib.csproj b/na-get-lib/na-get-lib.csproj index 09adf4b..6bf4078 100644 --- a/na-get-lib/na-get-lib.csproj +++ b/na-get-lib/na-get-lib.csproj @@ -48,6 +48,7 @@ + -- 2.11.0