修正htmlcxx中的几处bug

1.Node::parseAttributes 在解析这种<script> 完全没有属性的标签会有问题!
    原因:
    Node.cc(Line28)
    while (!isspace(*ptr))
    {
        ++ptr;//这种处理方式就断言了:tag名和'>'符号之间一定有空格
    }
    修改如下:
    while (!isspace(*ptr))
    {
        if(*ptr == '>')
            return;
        ++ptr;
    }

2.Node::parseAttributes 在解析这种:
    <script src=http://60.190.236.11:8000/stat.js?¨></script> 标签时会有问题!
    原因:
    stat.js?后面两个字节是a1 a7,(还有中文问题)显然不是ASCII表中的。
    而Node.cc(Line89) 有while (*end && !isspace(*end) && *end != '>') end++;
    其中isspace(*end)中会有如下断言:_ASSERTE((unsigned)(c + 1) <= 256); //要求调用者保证传入的参数必须属于ASCII码
    修改如下:
    //while (*end && !isspace(*end) && *end != '>') end++;
    while (*end &&((unsigned)*end > 255 || !isspace(*end) ) && *end != '>') end++;

3.ParserSax.tcc也存在如上相同问题:
    修改如下
    template <typename _Iterator>
    _Iterator
    htmlcxx::HTML::ParserSax::skipHtmlComment(_Iterator c, _Iterator end)
    {
        while ( c != end ) {
            if (*c++ == '-' && c != end && *c == '-')
            {
                _Iterator d(c);
                while (++c != end &&((unsigned)*c > 255 || !isspace(*c) ) && *c != '>');
                if (c == end || *c++ == '>') break;
                c = d;
            }
        }
    
        return c;
    }

转载于:https://my.oschina.net/leeeryan/blog/9914

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值