encrypted urlsegment
Started by Sevarf2, Oct 27 2011 03:03 AM
8 replies to this topic
#1
Posted 27 October 2011 - 03:03 AM
I have a page that i use for embedding a Streamed Malware like youtube, in this format:
wwww.domain.com/embed/videoid
Videoid is a string i generate crypted (urlSegment) and normally it ends with "=", ex. "/embed/mZ2Xp5g=".
Now, the urlSegment doesn't work with this type of string...the problem is the "=".
My solution for now is substr the = and add again when i need to decrypt the string but could be nice to have the entire string working...
wwww.domain.com/embed/videoid
Videoid is a string i generate crypted (urlSegment) and normally it ends with "=", ex. "/embed/mZ2Xp5g=".
Now, the urlSegment doesn't work with this type of string...the problem is the "=".
My solution for now is substr the = and add again when i need to decrypt the string but could be nice to have the entire string working...
#2
Posted 27 October 2011 - 06:19 AM
1. urlencode() and urldecode() dosent help?
2. cant you change the radnom (i guess) id generation to include only small/big letters and numerals, for instance?
2. cant you change the radnom (i guess) id generation to include only small/big letters and numerals, for instance?
#3
Posted 27 October 2011 - 07:33 AM
In addition to the expected forward slash to separate directories, ProcessWire only accepts these [ASCII] characters in it's URLs:
The same goes for page names (which make up URLs), and url segments. But it doesn't apply to GET vars of course.
In your case, I would probably use a GET var to hold that video ID. This would be more appropriate because URL segments really are more worthwhile for creating readable URLs, and hashes aren't by nature very readable.
But if you wanted to support those hashes in the URL, you could rtrim($urlSegment, '=') and add it back later, or just replace it with a dash or underscore, and add it back if needed.
abcdefghijklmnopqrstuvwxyz 0123456789 . - _
The same goes for page names (which make up URLs), and url segments. But it doesn't apply to GET vars of course.
In your case, I would probably use a GET var to hold that video ID. This would be more appropriate because URL segments really are more worthwhile for creating readable URLs, and hashes aren't by nature very readable.
But if you wanted to support those hashes in the URL, you could rtrim($urlSegment, '=') and add it back later, or just replace it with a dash or underscore, and add it back if needed.
#6
Posted 14 September 2012 - 06:34 AM
In addition to the expected forward slash to separate directories, ProcessWire only accepts these [ASCII] characters in it's URLs:
abcdefghijklmnopqrstuvwxyz 0123456789 . - _
The same goes for page names (which make up URLs), and url segments. But it doesn't apply to GET vars of course.
[...]
I have url segments which may contain characters out of this allowed list.
Did you consider also allowing '%' character in URLs ?
Having '%' would permit to use urlencode/urldecode functions.
Instead, I guess I have to write by own urlencode/urldecode function, or use base64_encode/base64_decode + handling the '=' characters which is somewhat overkill ;-)
Or do I overlook a simpler approach ?
#9
Posted 16 September 2012 - 12:13 PM
From the caching side, you can always use the MarkupCache module to cache your own stuff. But you just have to be careful so as limit the possible pages that can be rendered. Unbridled caching of pages generated as a result of values in GET vars is a bit of a security hole, as someone could take advantage and make you end up with millions of cache files, potentially filling up the disk or slowing things down. This is the reason why PW doesn't support caching of output generated as a result of URLs with GET variables.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users













