示例#1
0
        internal static bool GetQName(byte[] reply, ref int offset, ref string name)
        {
            bool retVal = GetQNameI(reply, ref offset, ref name);

            // Convert domain name to unicode. For more info see RFC 5890.
            System.Globalization.IdnMapping ldn = new System.Globalization.IdnMapping();
            name = ldn.GetUnicode(name);

            return(retVal);
        }
 public void TestUnicodeNegative()
 {
     foreach (var entry in Factory.GetDataset())
     {
         if (!entry.GetUnicodeResult.Success)
         {
             var map = new System.Globalization.IdnMapping();
             Assert.Throws <ArgumentException>(() => map.GetUnicode(entry.Source));
         }
     }
 }
示例#3
0
        /// <summary>Converts punycode back to unicode.</summary>
        public static string FromPunycode(string host)
        {
            if (host == null)
            {
                // not suitable.
                return(host);
            }

            System.Globalization.IdnMapping mapper = PunyMapper;

            return(mapper.GetUnicode(host));
        }
示例#4
0
        //代理商建站首页
        public ActionResult indexDl()
        {
            string domian = System.Web.HttpContext.Current.Request.Url.Host;

            if (string.IsNullOrEmpty(domian))
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "请求异常(域名不合法)!", code = "500"
                }));
            }

            if (domian.Contains(WebSiteConfig.DzWebSiteDomainExt))
            {
                //表示二级域名
                domian = domian.Replace(WebSiteConfig.DzWebSiteDomainExt, "");
            }
            if (domian.Contains("xn--"))//表示中文域名,会进行punycode编码 例如:www.九美.com   System.Web.HttpContext.Current.Request.Url.Host;实际拿到的是 www.xn--sjq221j.com
            {
                System.Globalization.IdnMapping idn = new System.Globalization.IdnMapping();

                domian = idn.GetUnicode(domian);
            }
            AgentWebSiteInfo agentWebSiteInfo = AgentWebSiteInfoBLL.SingleModel.GetModelByDomian(domian);

            if (agentWebSiteInfo == null)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "请求异常(没有数据)!", code = "500"
                }));
            }
            if (agentWebSiteInfo.webState == -1)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "网站已被停用(请联系客户)!", code = "403"
                }));
            }

            if (!string.IsNullOrEmpty(agentWebSiteInfo.seoConfig))
            {
                agentWebSiteInfo.seoConfigModel = JsonConvert.DeserializeObject <SeoConfigModel>(agentWebSiteInfo.seoConfig);
            }
            if (!string.IsNullOrEmpty(agentWebSiteInfo.pageMsgConfig))
            {
                agentWebSiteInfo.pageMsgConfigModel = JsonConvert.DeserializeObject <PageMsgConfigModel>(agentWebSiteInfo.pageMsgConfig);
            }



            return(View(agentWebSiteInfo));
        }
示例#5
0
        public void TestUnicodePositive()
        {
            foreach (var entry in Factory.GetDataset())
            {
                if (entry.GetUnicodeResult.Success)
                {
                    try
                    {
                        var map = new System.Globalization.IdnMapping { UseStd3AsciiRules = true, AllowUnassigned = true };
                        var unicodeResult = map.GetUnicode(entry.Source);

                        Assert.Equal(entry.GetUnicodeResult.Value, unicodeResult, StringComparer.OrdinalIgnoreCase);
                    }
                    catch (ArgumentException)
                    {
                        Assert.Equal(entry.GetUnicodeResult.Value, entry.Source, StringComparer.OrdinalIgnoreCase);
                    }
                }
            }
        }
        public void TestUnicodePositive()
        {
            foreach (var entry in Factory.GetDataset())
            {
                if (entry.GetUnicodeResult.Success)
                {
                    try
                    {
                        var map = new System.Globalization.IdnMapping {
                            UseStd3AsciiRules = true, AllowUnassigned = true
                        };
                        var unicodeResult = map.GetUnicode(entry.Source);

                        Assert.Equal(entry.GetUnicodeResult.Value, unicodeResult, StringComparer.OrdinalIgnoreCase);
                    }
                    catch (ArgumentException)
                    {
                        Assert.Equal(entry.GetUnicodeResult.Value, entry.Source, StringComparer.OrdinalIgnoreCase);
                    }
                }
            }
        }
示例#7
0
        internal static bool GetQName(byte[] reply,ref int offset,ref string name)
		{
            bool retVal = GetQNameI(reply,ref offset,ref name);

            // Convert domain name to unicode. For more info see RFC 5890.
            System.Globalization.IdnMapping ldn = new System.Globalization.IdnMapping();
            name = ldn.GetUnicode(name);

            return retVal;
        }
示例#8
0
 public void TestUnicodeNegative()
 {
     foreach (var entry in Factory.GetDataset())
     {
         if (!entry.GetUnicodeResult.Success)
         {
             var map = new System.Globalization.IdnMapping();
             Assert.Throws<ArgumentException>(() => map.GetUnicode(entry.Source));
         }
     }
 }