Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

url地址的验证存在问题 #1543

Open
hongweipeng opened this issue Mar 16, 2023 · 9 comments
Open

url地址的验证存在问题 #1543

hongweipeng opened this issue Mar 16, 2023 · 9 comments
Labels
question Further information is requested

Comments

@hongweipeng
Copy link
Contributor

1. 该问题的重现步骤是什么?

在后台的基本设置中设置站点地址

2. 你期待的结果是什么?实际看到的又是什么?

期待的结果是通过验证,实际看到的是不通过。

3. 问题出现的环境

Typecho 版本:v1.2.0;v1.1 则没有这个问题

image

找了下原因,是因为 v1.2 版本的typecho的 var/Typecho/Validate.php 的 url 验证改成了 filter_var($str, FILTER_VALIDATE_URL) ; 这个验证不允许 hostname 包含下划线,但显然我浏览器用这个地址可以正常的使用。

找了一下,也有看到在 php bugs 中提的帖子:https://bugs.php.net/bug.php?id=64948 ,目前对于这个的解决方案存在争议。

从使用上来说,hostname 中包含下划线在使用上并不算少见了,希望 typecho 可以改进下。

@joyqi
Copy link
Member

joyqi commented Mar 19, 2023

php的bug描述里也说了,根据rfc标准,hostname里就不应该使用下划线。

@hongweipeng
Copy link
Contributor Author

使用上是可以使用包含下划线的 hostname 的。

@Seevil
Copy link
Contributor

Seevil commented Mar 22, 2023

下划线的域名都注册都注册不了吧?

@hongweipeng
Copy link
Contributor Author

二级域名不用注册,在DNS里可以设置。

@Seevil
Copy link
Contributor

Seevil commented Mar 23, 2023

嗯嗯,你可以再想一想为什么注册不了。都注册不了的hostname 为什么要存在。个人建议你可以自己fork一份te的代码自己改做自己的定制化。

@hongweipeng
Copy link
Contributor Author

我是说不用去注册(尽管一级域名是注册不了),但可以在DNS里设置二级域名。使用上也是正常使用的,比如网址:http://dl_dir.qq.com/minigamefile/QQGameWorld.EXE

@vndroid
Copy link
Contributor

vndroid commented Apr 23, 2023

那你试试 cool_blog.xxx.com 能不能用,如果能用就没问题。

@fenbox
Copy link
Member

fenbox commented Jan 10, 2024

那你试试 cool_blog.xxx.com 能不能用,如果能用就没问题。

image

帮楼主试了下,确实不行。但确实存在包含下划线的二级域名。

@fenbox fenbox added the question Further information is requested label Jan 10, 2024
@cuixiping
Copy link

长见识了。

所以按标准是,域名不能含有下划线,但主机名可以。cool_blog.xxx.com 这个例子里,xxx.com是域名(注册时的那个),cool_blog.xxx.com是主机名(这里也是通俗说的子域名)。

那么,还有其它标点符号能用在主机名里面吗? @hongweipeng

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

6 participants