the login link on the forum doesn't really do what it insinuates it does.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dries’s picture

Status: Needs review » Needs work

Incorrect use of url(). Does $tid need to be escaped?

Wesley Tanaka’s picture

Status: Needs work » Needs review
FileSize
640 bytes

$tid is not escaped elsewhere in the function either because it is expected to be an integer.

Wesley Tanaka’s picture

Title: login link doesn't go back to forum » login link at top of forum index doesn't go back to forum
Wesley Tanaka’s picture

patch still applies against 4.7.0-test2

torgeirb’s picture

FileSize
751 bytes

If user does not actually have access to post in the forum, they are treated to a big fat 'access denied'. I'd rather they be redirected to the page they came from.

Alternatively, the login prompt on the forum needs to be removed if authenticated users are not allowed to create new forum topics.

moshe weitzman’s picture

that $tid looks dangerous to me. url() does not sanitize input. has the tid been sanitized already? otherwise, the intent of the patch is nice.

Wesley Tanaka’s picture

See comment #2:

$tid is not escaped elsewhere in the function either because it is expected to be an integer.

moshe weitzman’s picture

Status: Needs review » Needs work

that comment says nothing. "it is expected" does not cut it. we have to be sure that this input has been sanitized. this patch won't be accepted without proving that.

Wesley Tanaka’s picture

well, then the patch would need to be expanded to include all other times in the function that $tid is printed.

Wesley Tanaka’s picture

because the pre-existing code already assumes that $tid has been sanitized

puregin’s picture

Added code to ensure $tid is a numeric integer in this function; 'Login' link is generated according to torgeirb's patch.

puregin’s picture

FileSize
2.05 KB

Oops, here's the patch

moshe weitzman’s picture

i think a simple check_plain() solves the sanitizing need ... there is a line of debug code in there.

Wesley Tanaka’s picture

also the last change where you get rid of the check on $tid looks weird.

Wesley Tanaka’s picture

settype($tid, 'integer') would also work

puregin’s picture

I find typecasting and settype() have behaviours which don't seem appropriate here.

It looks like there are other places in the code where ensuring a given parameter is an integer is important, e.g.

http://drupal.org/node/41369

Is it best to clean up the parameters, or ignore them and just check_plain() the generated links?

Wesley Tanaka’s picture

settype would actually do a reasonable thing -- if the user created a url with a $tid that was completely not integer, settype would cast it to 0 which would give you the forum listing.

anyway, like i said back in comment #2, the original non-checking patch doesn't do any worse than the current code.

i don't care how it's done, and if it gives a better feeling of consensus, do check_plain like suggested in comment #13

Zen’s picture

Priority: Critical » Normal

Downgrading priority. Can someone provide a patch and get this rolling again?

Cheers
-K

Wesley Tanaka’s picture

Status: Needs work » Needs review

there are several patches that haven't been reviewed yet.

Dries’s picture

There is debug information in the last patch.

+  // insure $tid is an integer
+  if (isset($tid) && is_numeric($tid)) {
+      // could still be a numeric string; make it numeric
+      $tid = $tid + 0;
+      // if $tid is not an int, force it to zero
+      if (!is_int($tid)) {
+          $tid = 0;
+      }
+  }
+  else {
+    $tid = 0;
+  }
+ echo "theme_forum_display::tid = $tid<br/>\n";

How about using intval() instead?

chx’s picture

FileSize
1.31 KB

Usually this is what we do.

chx’s picture

FileSize
1.31 KB

hmmm, this time i did not want to double post.

chx’s picture

FileSize
605 bytes

definitely not three times. what's going on here?? what gets uploaded is not what i see.

gopherspidey’s picture

Status: Needs review » Reviewed & tested by the community

Before the Patch was applied the login link returned you to the begining of the site.

After the patch was applied it returned you to the same forum page so that I could post.

It applied cleanly to HEAD as of today

drumm’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD.

Anonymous’s picture

Status: Fixed » Closed (fixed)