diff --git a/Builder/IISMainHandler/build.txt b/Builder/IISMainHandler/build.txt index eaea6f5..e0c1820 100644 --- a/Builder/IISMainHandler/build.txt +++ b/Builder/IISMainHandler/build.txt @@ -1 +1 @@ -240 \ No newline at end of file +244 \ No newline at end of file diff --git a/ImportConsole/Program.cs b/ImportConsole/Program.cs index fd27d8f..2c299e8 100644 --- a/ImportConsole/Program.cs +++ b/ImportConsole/Program.cs @@ -42,7 +42,7 @@ namespace FLocal.ImportConsole { AbstractChange addAccount = new InsertChange( Account.TableSpec.instance, new Dictionary() { - { Account.TableSpec.FIELD_NAME, new ScalarFieldValue(userName) }, + { Account.TableSpec.FIELD_NAME, new ScalarFieldValue(userName.ToLower()) }, { Account.TableSpec.FIELD_NEEDSMIGRATION, new ScalarFieldValue("1") }, { Account.TableSpec.FIELD_PASSWORDHASH, new ScalarFieldValue("*") }, { Account.TableSpec.FIELD_USERID, new ReferenceFieldValue(addUser) }, diff --git a/Importer/ShallerConnector.cs b/Importer/ShallerConnector.cs index 024c26f..3aa7199 100644 --- a/Importer/ShallerConnector.cs +++ b/Importer/ShallerConnector.cs @@ -10,6 +10,12 @@ using System.IO; namespace FLocal.Importer { class ShallerConnector { + public static Encoding encoding { + get { + return Encoding.GetEncoding(1251); + } + } + public static string getPageContent(string requestUrl, Dictionary postData, CookieContainer cookies) { string baseUrl = ConfigurationManager.AppSettings["Importer_BaseUrl"]; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(baseUrl + requestUrl); @@ -21,9 +27,9 @@ namespace FLocal.Importer { StringBuilder postBuilder = new StringBuilder(); foreach(KeyValuePair kvp in postData) { - postBuilder.Append(HttpUtility.UrlEncode(kvp.Key)); + postBuilder.Append(HttpUtility.UrlEncode(kvp.Key, encoding)); postBuilder.Append('='); - postBuilder.Append(HttpUtility.UrlEncode(kvp.Value)); + postBuilder.Append(HttpUtility.UrlEncode(kvp.Value, encoding)); } byte[] postBytes = Encoding.ASCII.GetBytes(postBuilder.ToString()); @@ -39,7 +45,7 @@ namespace FLocal.Importer { request.UserAgent = "ShallerConnector v0.1"; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); cookies.Add(response.Cookies); - using(StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(1251))) { + using(StreamReader reader = new StreamReader(response.GetResponseStream(), encoding)) { return reader.ReadToEnd(); } } diff --git a/Importer/ShallerGateway.cs b/Importer/ShallerGateway.cs index eb006c5..f68e8fe 100644 --- a/Importer/ShallerGateway.cs +++ b/Importer/ShallerGateway.cs @@ -9,7 +9,8 @@ namespace FLocal.Importer { public class ShallerGateway { public static string getUserInfoAsString(string userName) { - return ShallerConnector.getPageContent("showprofile.php?User=" + userName + "&What=login&showlite=l", new Dictionary(), new System.Net.CookieContainer()); + //if(userName != HttpUtility.UrlEncode(userName, ShallerConnector.encoding)) throw new ApplicationException("'" + userName + "':showprofile.php?User=" + HttpUtility.UrlEncode(userName, ShallerConnector.encoding) + "&What=login&showlite=l"); + return ShallerConnector.getPageContent("showprofile.php?User=" + HttpUtility.UrlEncode(userName, ShallerConnector.encoding) + "&What=login&showlite=l", new Dictionary(), new System.Net.CookieContainer()); } private static Dictionary regexInfoCache = new Dictionary(); @@ -50,7 +51,7 @@ namespace FLocal.Importer { MatchCollection matches = matcher.Matches(content); HashSet result = new HashSet(); foreach(Match match in matches) { - result.Add(match.Groups[1].Value); + result.Add(HttpUtility.UrlDecode(match.Groups[1].Value, ShallerConnector.encoding).Trim()); } return result; }