1

This is a little out of the blue and it's mostly curiosity. I hope it's not a waste pf time and space. I was writing a little script to validate accounts with a link so I decided to send an email with a link to the php script and in the link I would put two variables to get with the _GET array. A key and the email. Then I would just search the database with that email and key and change it's activated status to true... No prob. Easy enough even though it may not be very elegant..

I used a script for the generation of the key that I used elsewhere in the site for generating a new password (to reset it for instance) but sometimes it didn't work and after a lot of tries I noticed (and I felt stupid then) that the array my password generation function drew from was this:

'0123456789_!@#$%&*()-=+abcdfghjkmnpqrstvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'

So naturally I deleted the & character that is used for separating variables in the url... Then in another try I noticed that the link in the email was not recognized whole and stopped after the '#' character as well which I then remembered is used for references in an html so I deleted that as well. In the end I decided to leave only alphanumeric characters to be sure but I am curious; Are ther any more characters that are not 'valid' for url's using utilizing _GET and is there any way to use those characters anyway (maybe ulr encode or somwething)

4

3 回答 3

2

有很多无效的字符。用于urlencode将它们转换为 URL 安全编码。(始终在您插入 URL的任何数据上运行该函数)。

于 2012-08-07T12:49:28.027 回答
0

您必须urlencode()在将值发送到$_GET.

于 2012-08-07T12:49:47.237 回答
0

你可以使用url_encodeurl_decode但我会远离& # ?这些是正常的 URL 字符。

同样,当涉及到密码时:不要强调算法,使用sha1 crypt或类似的东西salt。这些算法将比您自制的算法强大得多。

于 2012-08-07T12:50:22.723 回答