分类目录归档:杂记

在 CDATA 节中找到无效的 XML 字符 (Unicode: 0x1f)

https://blog.csdn.net/dufufd/article/details/53895764

在 CDATA 节中找到无效的 XML 字符 (Unicode: 0x1f)

String could not be parsed as XML

解析XML文件时,会碰到程序发生以下一些异常信息: 

在 CDATA 节中找到无效的 XML 字符 (Unicode: 0x1f)。

或者:

An invalid XML character (Unicode: 0x1f) was found in the CDATA section.

这些错误的发生是由于一些不可见的特殊字符的存在,而这些字符对于XML文件来说又是非法的,所以XML解析器在解析时会发生异常,官方定义了XML的无效字符分为三段: 

0x00 – 0x08

0x0b – 0x0c

0x0e – 0x1f

解决方法是:在解析之前先把字符串中的这些非法字符过滤掉即可, 不会影响原来文本的内容。

即:string.replaceAll(“[\\x00-\\x08\\x0b-\\x0c\\x0e-\\x1f]”, “”) ;

# php 版过滤方法
$content2 = preg_replace(‘/[\\x00-\\x08\\x0b-\\x0c\\x0e-\\x1f]/mu’, ”, $content);

另外:这些字符即使放在CDATA中仍然解析不了,所以最好的办法是过滤掉。

分享一组需要屏蔽的垃圾IP

46.229.168.162
46.229.168.144
46.229.168.151
46.229.168.143
46.229.168.153
46.229.168.149
46.229.168.154
46.229.168.145
46.229.168.133
46.229.168.147
46.229.168.139
46.229.168.137
46.229.168.131
46.229.168.163
46.229.168.146
46.229.168.140
46.229.168.135
46.229.168.130
46.229.168.134
46.229.168.148
46.229.168.136
46.229.168.141
3.234.214.179
46.229.168.152
46.229.168.138
46.229.168.129
46.229.168.142
46.229.168.161
46.229.168.132
46.229.168.150

IPv6字符串表示最大长度(字符数)

45个字符,数据库设计时存储IPv6需要 varchar(45)

45 characters.

You might expect an address to be

0000:0000:0000:0000:0000:0000:0000:0000

8 * 4 + 7 = 39

8 groups of 4 digits with 7 : between them.

But if you have an IPv4-mapped IPv6 address, the last two groups can be written in base 10 separated by ., eg. [::ffff:192.168.100.228]. Written out fully:

0000:0000:0000:0000:0000:ffff:192.168.100.228

(6 * 4 + 5) + 1 + (4 * 3 + 3) = 29 + 1 + 15 = 45

Note, this is an input/display convention – it’s still a 128 bit address and for storage it would probably be best to standardise on the raw colon separated format, i.e. [0000:0000:0000:0000:0000:ffff:c0a8:64e4] for the address above.

docker初探小记


# 启动个nginx
docker run --detach --publish 80:80 --name webserver nginx
# 停止nginx
docker container stop webserver
# 删除容器
docker container rm webserver

–detach等于-d 后后台运行的意思

可参考链接:
http://www.runoob.com/docker/docker-command-manual.html

CentOS 7安装docker:

yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce docker-ce-cli containerd.io