Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Make sure file or folder exists before sharing.
Browse files Browse the repository at this point in the history
Short hash with numbers only can be interpreted as integer and checkHash send false negative.
  • Loading branch information
cdujeu committed Dec 15, 2013
1 parent 952fd83 commit cd26aa1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/src/plugins/action.share/class.ShareCenter.php
Expand Up @@ -123,6 +123,9 @@ public function switchAction($action, $httpVars, $fileVars)
$subAction = (isSet($httpVars["sub_action"])?$httpVars["sub_action"]:"");
$file = AJXP_Utils::decodeSecureMagic($httpVars["file"]);
$ajxpNode = new AJXP_Node($this->urlBase.$file);
if(!file_exists($ajxpNode->getUrl())){
throw new Exception("Cannot share a non-existing file: ".$ajxpNode->getUrl());
}
$metadata = null;

if ($subAction == "delegate_repo") {
Expand Down Expand Up @@ -673,7 +676,7 @@ public function computeHash($outputData, $checkInFolder = null)
public static function checkHash($outputData, $hash)
{
$full = md5($outputData);
return (!empty($hash) && strpos($full, $hash) === 0);
return (!empty($hash) && strpos($full, $hash."") === 0);
}

public function buildPublicDlURL()
Expand Down

0 comments on commit cd26aa1

Please sign in to comment.