Skip to content

Commit

Permalink
Merge pull request #10531 from jeabakker/comment-redirector
Browse files Browse the repository at this point in the history
fix(comments): comment redirector URL no longer contain double fragments
  • Loading branch information
jdalsem committed Oct 26, 2016
2 parents 116b9eb + 37f578e commit 7675226
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
17 changes: 11 additions & 6 deletions engine/lib/comments.php
Expand Up @@ -113,9 +113,14 @@ function _elgg_comment_redirect($comment_guid, $fallback_guid) {
}

$url = elgg_http_add_url_query_elements($container->getURL(), [
'offset' => $offset,
]) . "#elgg-object-{$comment->guid}";

'offset' => $offset,
]);

// make sure there's only one fragment (#)
$parts = parse_url($url);
$parts['fragment'] = "elgg-object-{$comment->guid}";
$url = elgg_http_build_url($parts, false);

forward($url);
}

Expand Down Expand Up @@ -209,7 +214,7 @@ function _elgg_comments_container_permissions_override($hook, $type, $return, $p

/**
* By default, only authors can edit their comments.
*
*
* @param string $hook 'permissions_check'
* @param string $type 'object'
* @param boolean $return Can the given user edit the given entity?
Expand Down Expand Up @@ -273,12 +278,12 @@ function _elgg_comments_notification_email_subject($hook, $type, $returnvalue, $

/**
* Update comment access to match that of the container
*
*
* @param string $event 'update:after'
* @param string $type 'all'
* @param ElggEntity $entity The updated entity
* @return bool
*
*
* @access private
*/
function _elgg_comments_access_sync($event, $type, $entity) {
Expand Down
9 changes: 7 additions & 2 deletions mod/discussions/start.php
Expand Up @@ -191,8 +191,13 @@ function discussion_redirect_to_reply($reply_guid, $fallback_guid) {
}

$url = elgg_http_add_url_query_elements($topic->getURL(), [
'offset' => $offset,
]) . "#elgg-object-{$reply->guid}";
'offset' => $offset,
]);

// make sure there's only one fragment (#)
$parts = parse_url($url);
$parts['fragment'] = "elgg-object-{$reply->guid}";
$url = elgg_http_build_url($parts, false);

forward($url);
}
Expand Down

0 comments on commit 7675226

Please sign in to comment.