Flex 电子邮件验证器 - £域名中允许使用的符号

发布于 2024-11-02 04:41:40 字数 905 浏览 1 评论 0原文

我在工作中需要修复一个错误,其中域名中允许使用英镑符号 £。

我检查了 EmailValidator 源代码,可以看到它不是不允许的符号,而美元符号之类的符号是:

public class EmailValidator extends Validator
{
    include "../core/Version.as";

    //--------------------------------------------------------------------------
    //
    //  Class constants
    //
    //--------------------------------------------------------------------------

    /**
     *  @private
     */
    private static const DISALLOWED_LOCALNAME_CHARS:String =
                                "()<>,;:\\\"[] `~!#$%^&*={}|/?'";
    /**
     *  @private
     */                         
    private static const DISALLOWED_DOMAIN_CHARS:String =
                                "()<>,;:\\\"[] `~!#$%^&*+={}|/?'";

如您所见 DISALLOWED_DOMAIN_CHARS 字符串不包含 £ 符号。正在考虑猴子修补(基本上是复制整个类,编辑它,并将其添加到我的 src - 对于那些不知道的人),但我们使用 RSL,所以这会出现问题。

大家有什么想法吗?

I have a bug to fix in work where the UK Pound symbol, £, is allowed in the domain name.

I checked the EmailValidator source and can see that it is not a disallowed symbol, whereas things like the dollar sign are:

public class EmailValidator extends Validator
{
    include "../core/Version.as";

    //--------------------------------------------------------------------------
    //
    //  Class constants
    //
    //--------------------------------------------------------------------------

    /**
     *  @private
     */
    private static const DISALLOWED_LOCALNAME_CHARS:String =
                                "()<>,;:\\\"[] `~!#$%^&*={}|/?'";
    /**
     *  @private
     */                         
    private static const DISALLOWED_DOMAIN_CHARS:String =
                                "()<>,;:\\\"[] `~!#$%^&*+={}|/?'";

As you can see DISALLOWED_DOMAIN_CHARS string does not include the £ sign. Was thinking of monkey patching (basically copying the entire class, editing it, and adding it to my src - for those not in the know), but we use RSL's, so that would be problematic.

Any ideas folks?

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

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

发布评论

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

评论(2

街道布景 2024-11-09 04:41:40

我认为您应该像这样重写类 mx.validators.EmailValidator 的方法 doValidation 而不是克隆一个

override protected function doValidation(value:Object):Array
        {
            var results:Array =  super.doValidation(value);

            var emailStr:String = String(value);
            var poundPos:int = emailStr.indexOf("£");
            if (poundPos != -1)
            {
                results.push(new ValidationResult(
                    true, null, "invalidChar",
                    this.invalidCharError));

            }

            return results;                      
        }

有帮助的类 Hopes

I think You should override the method doValidation of Class mx.validators.EmailValidator like this rather than clone a Class

override protected function doValidation(value:Object):Array
        {
            var results:Array =  super.doValidation(value);

            var emailStr:String = String(value);
            var poundPos:int = emailStr.indexOf("£");
            if (poundPos != -1)
            {
                results.push(new ValidationResult(
                    true, null, "invalidChar",
                    this.invalidCharError));

            }

            return results;                      
        }

Hopes that helps

瀞厅☆埖开 2024-11-09 04:41:40

为什么您需要禁止它?

这个反问句是由数字 42 以及字母 S 和 O 带来的。


还有许多其他符号,您不会要求专门禁止。我建议决定像现在一样将“仅少数”列入黑名单,或者完全重新考虑您的验证过程以采用白名单格式。

Why do you need to disallow it?

This rhetorical question brought to you by the number 42 and the letters S and O.


There are so many other symbols that you're not asking about specifically banning. I'd suggest deciding to blacklist "only a few" like you are now, or else completely rethink your validation process to a whitelist format.

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