Skip to content

Commit

Permalink
Make sorting work ("AskReddit/hot" or whatnot).
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Feb 13, 2018
1 parent 79df491 commit cfb4d1b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion feed/index.php
Expand Up @@ -332,7 +332,7 @@ function verify_cache($fname, $url, $subreddit, $maxage)
{
$use_google = false; // these tend to be broken on Google Reader. :/
$str = $_REQUEST['subreddit'];
if ((strlen($str) < 32) && (preg_match('/^[a-zA-Z0-9\-_]+$/', $str) == 1))
if ((strlen($str) < 32) && (preg_match('/^[\\a-zA-Z0-9\-_]+$/', $str) == 1))
{
$cachefname = "$str-$cachefname";
$feedurl .= "r/$str/";
Expand Down Expand Up @@ -433,6 +433,9 @@ function verify_cache($fname, $url, $subreddit, $maxage)
if ($staging)
$cachefname = "$cachefname-staging";

// make sure "subreddit/sorting" doesn't look like a subdir.
$cachefname = strtr($cachefname, '/', '_');

if (!verify_cache($cachefname, $feedurl, $subreddit, 60))
{
header('HTTP/1.0 503 Service unavailable');
Expand Down

0 comments on commit cfb4d1b

Please sign in to comment.