Project.Common/CommonFun.cs
(开头部分) 13KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Web;
using System.Web.UI;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Web.Security;
using System.IO;
using System.Text.RegularExpressions;
using System.Configuration;
using System.Data;
using System.Text;
using System.Collections.Generic;
using System.Xml.Serialization;
namespace Project.Common
{
public class CommonFun
{
/// <summary>
/// 从网页编辑器中获取全部图片url
/// </summary>
/// <param name="str">编辑器内容</param>
/// <returns>图片url列表</returns>
public static List<string> GetUrlsFromEidtor(string str)
{
List<string> list = new List<string>();
Regex reg = new Regex(@"(?i)<img\b[^>]*?src=(['""]?)([^'""\s>]+)\1[^>]*>");
MatchCollection mc = reg.Matches(str);
foreach (Match m in mc)
{
list.Add(m.Groups[2].Value);
}
return list;
}
/// <summary>
/// 此方法用于确认用户输入的不是恶意信息
/// </summary>
/// <param name="text">用户输入信息</param>
/// <param name="maxLength">输入的最大长度</param>
/// <returns>处理后的输入信息</returns>
public static string InputText(string text, int maxLength)
{
if (string.IsNullOrEmpty(text))
return string.Empty;
if (string.IsNullOrEmpty(text.Trim()))
return string.Empty;
if (text.Length > maxLength)
text = text.Substring(0, maxLength);
//将网页中非法和有攻击性的符号替换掉,以防sql注入!返回正常数据
text = Regex.Replace(text, "[\\s]{2,}", " "); // 2个或以上的空格
text = Regex.Replace(text, "(<[b|B][r|R]/*>)+|(<[p|P](.|\\n)*?>)", "\n"); //<br> html换行符
text = Regex.Replace(text, "(\\s*&[n|N][b|B][s|S][p|P];\\s*)+", " "); // html空格符
text = Regex.Replace(text, "<(.|\\n)*?>", string.Empty); // 任何其他的标签
text = text.Replace("'", "''");// 单引号
return text;
}
/// <summary>
后面还有 271 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。