如何在 ASP 中阻止垃圾邮件链接

发布于 2024-09-27 13:23:51 字数 642 浏览 0 评论 0原文

在php中,我们使用以下代码来阻止通过表单提交上的文本框或文本区域传递的url链接(以避免

从“联系我们”表单传递错误链接)。在使用vb的经典asp中是否有类似的方法?

if($_POST['Register'])
{
    $username=$_POST['username'];
    if (preg_match('~(?:[a-z0-9+.-]+://)?(?:\w+\.)+\w{2,6}\S*~i', $username))
    {
         die('Access Denied Avoid Link');

    }
}

我在asp中使用以下代码但显示错误

<%@Language="VBScript%">
<%
Option Explicit

Dim Address 
Address = Request("Address") 

if(!preg_match("/^[a-zA-Z]+[:\/\/]+[A-Za-z0-9\-_]+\\.+[A-Za-z0-9\.\/%&=\?\-_]+$/i",& Address&))
{
Echo"Access Denied Avoid Link.";
Response.End
'Exit();
}
%>

In php we use the following code to block the url link passing via text boxes or textarea on form submit(For avoid bad link

passing from contact us form ).Is there any methode like this in classic asp using vb.

if($_POST['Register'])
{
    $username=$_POST['username'];
    if (preg_match('~(?:[a-z0-9+.-]+://)?(?:\w+\.)+\w{2,6}\S*~i', $username))
    {
         die('Access Denied Avoid Link');

    }
}

I use the following code in asp but shows error

<%@Language="VBScript%">
<%
Option Explicit

Dim Address 
Address = Request("Address") 

if(!preg_match("/^[a-zA-Z]+[:\/\/]+[A-Za-z0-9\-_]+\\.+[A-Za-z0-9\.\/%&=\?\-_]+$/i",& Address&))
{
Echo"Access Denied Avoid Link.";
Response.End
'Exit();
}
%>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

满身野味 2024-10-04 13:23:51

您需要使用 RegExp 对象,一个简单的例子是

Dim re
Set re = New RegExp

re.Pattern = "^Hello.*" ' Replace with your regexp pattern
re.IgnoreCase = True

result = re.Test("Hello world") ' Returns boolean
If result Then
   ' Found!
Else
   ' Not found :-(
End If
Set re = Nothing

VBScript 中的正则表达式语法可能与 PHP 略有不同,因此您可能需要稍微翻译一下正则表达式。请参阅 http://msdn.microsoft.com/en-us/library/ms974570。有关 Microsoft RegExp 类的更多详细信息,请访问 aspx

You'll need to use the RegExp object, a simple example being

Dim re
Set re = New RegExp

re.Pattern = "^Hello.*" ' Replace with your regexp pattern
re.IgnoreCase = True

result = re.Test("Hello world") ' Returns boolean
If result Then
   ' Found!
Else
   ' Not found :-(
End If
Set re = Nothing

Regular Expression grammar in VBScript is likely to be a little different to PHP, so you may need to translate your regular expression slightly. See http://msdn.microsoft.com/en-us/library/ms974570.aspx for more details on Microsoft's RegExp class.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文