導航:首頁 > 凈水問答 > asp過濾特殊字元串

asp過濾特殊字元串

發布時間:2022-09-17 01:11:18

1. asp 過濾字元串中的某些字元

循環讀取每一行放在數組裡面
s="[00:02.00]歌曲:月半小夜曲"
s=left(s,5)&right(s,len(s)-8)
response.write s

2. 在asp中怎麼過濾用戶輸入的非法字元

<%
dim texts
texts=request("表單明")

dim kill '要過濾的字元
kill="牆,垃,圍毆" '比喻

dim rsss
rsss=split(kill,",")
dim i,xxxx,yyyy
for i=0 to ubound(rsss)
xxxx=len(rsss(i))
dim j
for j=1 to xxxx
yyyy=yyyy&"*"
next
dim zzzz '過濾後的字元串
if i=0 then zzzz=texts
'如果你想把過濾字版符換成*
zzzz=replace(zzzz,rsss(i),yyyy)
'如果你想把過濾字元直接去掉
zzzz=replace(zzzz,rsss(i),"")
next

'zzzz就是過權濾後的字元了
%>

3. asp中過濾掉一段字元串

<%
a="44hello456789hello"
a=split(a,"hello")
'以hello為分割符,將a分成多個部分,只取前後兩個部分就行了
newa=a(lbound(a))& a(ubound(a))
Response.Write(newa)
%>
樓下的就不對了,
樓主是想把兩個過濾符之間的字元串也刪掉呢
你那樣是只是把過濾符刪掉了,如果只是刪掉過濾符的話.這樣最簡單了
newa=replace(a,"hello")

4. 求ASP代碼過濾指定字元串

高了半天可以了:
註:.txt里的內容應用「,」分開注意逗號的中英文形式:如下
我愛你,
不和諧,
很和諧

<?php
$fileurl = "123.txt";//txt路徑

$objtxt = fopen($fileurl,"r");

$strtxt = fread($objtxt,filesize($fileurl));
echo "要替換的字元:".$strtxt."<br />";

$arrtxt = explode(",",$strtxt); //轉成數組;

$str = "這樣做是可以的,如果有我愛你,就要被替換了";
echo "替換的字元:".$strtxt."<br />";

$replace = "8888";
echo "把替換字元替換為:".$replace."<br />";

for($i=0;$i<count($arrtxt);$i++){
if(substr_count($str,$arrtxt[$i]) > 0 ){
$str = str_replace($arrtxt[$i],$replace,$str);
}
}
echo "替換後:".$str;
?>

我這里測試成功;有不懂再問。
希望我的回答對你有幫助。

5. 在asp.net傳遞參數怎麼過濾特殊字元

1.傳遞前先加密 ,KEY是你自己定義的,加密解密函數KEY一致。
public static string Encode(string str, string key)
{
DESCryptoServiceProvider provider = new DESCryptoServiceProvider();
provider.Key = Encoding.ASCII.GetBytes(key.Substring(0, 8));
provider.IV = Encoding.ASCII.GetBytes(key.Substring(0, 8));
byte[] bytes = Encoding.GetEncoding("GB2312").GetBytes(str);
MemoryStream stream = new MemoryStream();
CryptoStream stream2 = new CryptoStream(stream, provider.CreateEncryptor(), CryptoStreamMode.Write);
stream2.Write(bytes, 0, bytes.Length);
stream2.FlushFinalBlock();
StringBuilder builder = new StringBuilder();
foreach (byte num in stream.ToArray())
{
builder.AppendFormat("{0:X2}", num);
}
stream.Close();
return builder.ToString();
}
2.獲取參數後,解密
/// <summary>
/// Des 解密 GB2312
/// </summary>
/// <param name="str">Desc string</param>
/// <param name="key">Key ,必須為8位 </param>
/// <returns></returns>
public static string Decode(string str, string key)
{
try
{
DESCryptoServiceProvider provider = new DESCryptoServiceProvider();
provider.Key = Encoding.ASCII.GetBytes(key.Substring(0, 8));
provider.IV = Encoding.ASCII.GetBytes(key.Substring(0, 8));
byte[] buffer = new byte[str.Length / 2];
for (int i = 0; i < (str.Length / 2); i++)
{
int num2 = Convert.ToInt32(str.Substring(i * 2, 2), 0x10);
buffer[i] = (byte)num2;
}
MemoryStream stream = new MemoryStream();
CryptoStream stream2 = new CryptoStream(stream, provider.CreateDecryptor(), CryptoStreamMode.Write);
stream2.Write(buffer, 0, buffer.Length);
stream2.FlushFinalBlock();
stream.Close();
return Encoding.GetEncoding("GB2312").GetString(stream.ToArray());
}
catch (Exception)
{
return "";
}
}

6. asp 網站發現有注入漏洞 and 1=2 報錯。 請問如何在 asp 的資料庫裡面過濾這些字元。

SQL注入漏洞一般是通過程序將特殊字元去掉的,基本方法如下:

  1. 在將字元串傳入SQL語句之前先通過一個函數進行檢測,如果其中包含了and、or、update、delete等信息,則報錯。

  2. 在資料庫的命名規則中要進行一些前綴處理,不要用通常的命名規則去命名表和欄位,比如用戶表,不用users或者tbusers,而是採取esc_tbusers,這樣在一定程度上也能防止SQL注入的問題。

7. asp 過濾字元串問題

嗯嗯,我有辦法。送你一個過濾函數(僅保留<br>標簽)。
<%
function filterhtml(byval fstring)

if isnull(fstring) or trim(fstring)="" then

filterhtml=""

exit function

end if

fstring = replace(fstring, "

", "[br]")

fstring = replace(fstring, "

", "[br]")

'過濾html標簽

dim re

set re = new regexp

re.ignorecase=true

re.global=true

re.pattern="<(.+?)>"

fstring = re.replace(fstring, "")

set re=nothing

fstring = replace(fstring, "[br]", "

")

filterhtml = fstring

end function
%>

8. ASP字元過濾。

username=trim(request.form("username"))
'定義一個數組
badCode="<,%,@,upload"
'分割數據
badCode=split(badCode,",")
'從第一個循環到最後一個
for i = 0 to ubound(badCode)
username=replace(username,badCode(i),"") '把這專些字元替換屬為空
next

閱讀全文

與asp過濾特殊字元串相關的資料

熱點內容
ro膜不排廢水有效果嗎 瀏覽:53
怪獵純水晶打什麼怪掉 瀏覽:310
飲水機水流大小怎麼調 瀏覽:611
用樹脂修復屏幕玻璃 瀏覽:523
凈化器排氣管用什麼樣的 瀏覽:575
森森瀑布過濾器進去魚 瀏覽:857
純水機不制水為什麼還有廢水 瀏覽:549
光明村濕地污水處理 瀏覽:329
處理一頓廢水多少錢 瀏覽:376
汽油濾芯怎麼破拆 瀏覽:290
污水處理站維護記錄 瀏覽:816
脫硫廢水復合葯劑 瀏覽:911
日產奇駿2016空調濾芯怎麼拆 瀏覽:59
大眾車載空氣凈化器效果怎麼樣 瀏覽:331
反滲透凈水器不出水是什麼原因 瀏覽:180
小米空氣濾芯怎麼驗證真假 瀏覽:84
飲水機怎麼拆裝 瀏覽:880
透析用反滲透膜 瀏覽:865
創星過濾桶聲音大是什麼原因 瀏覽:572
別克威朗空氣濾芯4s店多少錢 瀏覽:265