CS(CommunityServer)2.0树视图新建分类、版块、相册、博客时使用中文造成错误的bug修正
不少朋友都遇到了使用树视图添加分类,相册或者博客时使用中文,或者忘记填写唯一名称,造成cs挂掉的问题。
要是你分析了源码,就发现这个问题实际上是因为中文造成的,每个目录类别等都需要一个英文的不重复的applicationKey,而你用树形视图添加板块,就会造成没有这个参数,所以就出错拉,简单处理就使使用网格视图添加,并注意指定appKey,或者修改源码,当检测不到appKey时,随机分配一个 。
不过最好的还是修改源代码,抓出这个bug:
找到Global.cs,修改一下方法:
public static bool ValidateApplicationKey(string appKey, out string formattedKey)
{
formattedKey = appKey.Trim().Replace(" ", "_").ToLower();
formattedKey = System.Text.RegularExpressions.Regex.Replace(formattedKey, "[^0-9a-zA-Z_\-]", "");
//Should we remove these items? Or just encode them. We can change this logic
//string[] parts = formattedKey.Split('!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '[', ']', '{', '}', '<', '>', ',', '?', '\', '/', ''','+','=','~','`','|');
//formattedKey = string.Join("", parts);
//edit by lonestone 2006-7-22 chinese surport
if (formattedKey == null || formattedKey == string.Empty)
{
Random rd = new Random();
formattedKey = "New" + rd.Next(10000).ToString();
}
formattedKey = Globals.UrlEncode(formattedKey);
return formattedKey == appKey;
}
样在新建板块的时候就会自动检查,如果没有appkey,则自动分配一个,稍后修改即可,不过要注意不能重复。
重新编译,问题解决。
from: http://blog.csdn.net/lonestone/archive/2006/08/14/1062941.aspx
浙公网安备 33010602011771号