mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 04:20:55 +01:00
Fix regenerate arcanist cert, setup stuff and avoid accept non valid image files as profile picture.
Summary: Well, since I couldn't regenerate my arcanist cert I figured out that this wass because "workflows" are unavailable there now. I really can not figure out why but it was. I added in the setup script, the ability to check if is present the protocol of the host and if it has a trailing slash a the end of the line, since both are needed to generate the cert. Users now only be able to upload valid image files with mimetype of jpg, jpeg, png and gif. Test Plan: FIRST: DO NOT apply those changes! then 1- go to settings->arcanist certificate and the click on regenerate ... humm 2- On your config file, delete the trailing slash at the end and the protocol on "phabricator.base-uri", then go to setting->arcanist certificate. Here you will see something like this "phabricator.example.comapi\/" instead of "http:\/\/phabricator.example.com\/api\/". SECOND: Now apply this changes: 1- Go to settings->arcanist certificate and the click on regenerate. 2- On your config file, delete the trailing slash at the end and the protocol on "phabricator.base-uri", and setup "phabricator.setup" to true. 3- Then go to setting->arcanist certificate and you could see that this was successfully generated. THIRD: Go to settings->account and try to upload an invalid image file, and do the same on "youruserna"->edit profile. Reviewed By: epriestley Reviewers: epriestley jungejason CC: epriestley jugesason cadamo aran Differential Revision: 391
This commit is contained in:
parent
a63274289c
commit
089d8327b3
5 changed files with 64 additions and 32 deletions
|
@ -32,7 +32,7 @@ class PhabricatorPeopleProfileEditController
|
||||||
$profile->setUserPHID($user->getPHID());
|
$profile->setUserPHID($user->getPHID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$errors = array();
|
||||||
if ($request->isFormPost()) {
|
if ($request->isFormPost()) {
|
||||||
$profile->setTitle($request->getStr('title'));
|
$profile->setTitle($request->getStr('title'));
|
||||||
$profile->setBlurb($request->getStr('blurb'));
|
$profile->setBlurb($request->getStr('blurb'));
|
||||||
|
@ -41,14 +41,29 @@ class PhabricatorPeopleProfileEditController
|
||||||
$err = idx($_FILES['image'], 'error');
|
$err = idx($_FILES['image'], 'error');
|
||||||
if ($err != UPLOAD_ERR_NO_FILE) {
|
if ($err != UPLOAD_ERR_NO_FILE) {
|
||||||
$file = PhabricatorFile::newFromPHPUpload($_FILES['image']);
|
$file = PhabricatorFile::newFromPHPUpload($_FILES['image']);
|
||||||
$profile->setProfileImagePHID($file->getPHID());
|
$okay = $file->isTransformableImage();
|
||||||
|
if ($okay) {
|
||||||
|
$profile->setProfileImagePHID($file->getPHID());
|
||||||
|
} else {
|
||||||
|
$errors[] =
|
||||||
|
'Only valid image files (jpg, jpeg, png or gif) '.
|
||||||
|
'will be accepted.';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile->save();
|
if (!$errors) {
|
||||||
$response = id(new AphrontRedirectResponse())
|
$profile->save();
|
||||||
->setURI('/p/'.$user->getUsername().'/');
|
$response = id(new AphrontRedirectResponse())
|
||||||
return $response;
|
->setURI('/p/'.$user->getUsername().'/');
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($errors) {
|
||||||
|
$error_view = new AphrontErrorView();
|
||||||
|
$error_view->setTitle('Form Errors');
|
||||||
|
$error_view->setErrors($errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
$form = new AphrontFormView();
|
$form = new AphrontFormView();
|
||||||
|
@ -88,10 +103,13 @@ class PhabricatorPeopleProfileEditController
|
||||||
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
|
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
|
||||||
|
|
||||||
return $this->buildStandardPageResponse(
|
return $this->buildStandardPageResponse(
|
||||||
$panel,
|
array(
|
||||||
|
$error_view,
|
||||||
|
$panel,
|
||||||
|
),
|
||||||
array(
|
array(
|
||||||
'title' => 'Edit Profile',
|
'title' => 'Edit Profile',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -15,9 +15,10 @@ phutil_require_module('phabricator', 'view/form/control/file');
|
||||||
phutil_require_module('phabricator', 'view/form/control/submit');
|
phutil_require_module('phabricator', 'view/form/control/submit');
|
||||||
phutil_require_module('phabricator', 'view/form/control/text');
|
phutil_require_module('phabricator', 'view/form/control/text');
|
||||||
phutil_require_module('phabricator', 'view/form/control/textarea');
|
phutil_require_module('phabricator', 'view/form/control/textarea');
|
||||||
|
phutil_require_module('phabricator', 'view/form/error');
|
||||||
phutil_require_module('phabricator', 'view/layout/panel');
|
phutil_require_module('phabricator', 'view/layout/panel');
|
||||||
|
|
||||||
phutil_require_module('phutil', 'utils');
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
phutil_require_source('PhabricatorPeopleProfileEditController.php');
|
phutil_require_source('PhabricatorPeopleProfileEditController.php');
|
|
@ -118,14 +118,22 @@ class PhabricatorUserSettingsController extends PhabricatorPeopleController {
|
||||||
$err = idx($_FILES['profile'], 'error');
|
$err = idx($_FILES['profile'], 'error');
|
||||||
if ($err != UPLOAD_ERR_NO_FILE) {
|
if ($err != UPLOAD_ERR_NO_FILE) {
|
||||||
$file = PhabricatorFile::newFromPHPUpload($_FILES['profile']);
|
$file = PhabricatorFile::newFromPHPUpload($_FILES['profile']);
|
||||||
$user->setProfileImagePHID($file->getPHID());
|
$okay = $file->isTransformableImage();
|
||||||
|
|
||||||
|
if ($okay) {
|
||||||
|
$user->setProfileImagePHID($file->getPHID());
|
||||||
|
} else {
|
||||||
|
$errors[] =
|
||||||
|
'Only valid image files (jpg, jpeg, png or gif) '.
|
||||||
|
'will be accepted.';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$user->setRealName($request->getStr('realname'));
|
$user->setRealName($request->getStr('realname'));
|
||||||
|
|
||||||
if (!strlen($user->getRealName())) {
|
if (!strlen($user->getRealName())) {
|
||||||
$errors[] = 'Real name must be nonempty';
|
$errors[] = 'Real name must be nonempty.';
|
||||||
$e_realname = 'Required';
|
$e_realname = 'Required';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,7 +253,6 @@ class PhabricatorUserSettingsController extends PhabricatorPeopleController {
|
||||||
$regen_form = new AphrontFormView();
|
$regen_form = new AphrontFormView();
|
||||||
$regen_form
|
$regen_form
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
->setWorkflow(true)
|
|
||||||
->setAction('/settings/page/arcanist/')
|
->setAction('/settings/page/arcanist/')
|
||||||
->appendChild(
|
->appendChild(
|
||||||
'<p class="aphront-form-instructions">You can regenerate this '.
|
'<p class="aphront-form-instructions">You can regenerate this '.
|
||||||
|
@ -526,7 +533,5 @@ class PhabricatorUserSettingsController extends PhabricatorPeopleController {
|
||||||
|
|
||||||
return $notice.$panel->render();
|
return $notice.$panel->render();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
|
@ -130,18 +130,28 @@ class PhabricatorSetup {
|
||||||
self::writeDoc('article/Configuration_Guide.html');
|
self::writeDoc('article/Configuration_Guide.html');
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
self::write(" okay Custom configuration loaded.\n");
|
$host = PhabricatorEnv::getEnvConfig('phabricator.base-uri');
|
||||||
}
|
$protocol = id(new PhutilURI($host))->getProtocol();
|
||||||
|
if (!($protocol === 'http') || !($protocol === 'https')) {
|
||||||
if (!PhabricatorEnv::getEnvConfig('phabricator.base-uri')) {
|
self::writeFailure();
|
||||||
self::writeFailure();
|
self::write(
|
||||||
self::write(
|
"You must specify the protocol over which your host works (e.g.: ".
|
||||||
"Setup failure! You must specify 'phabricator.base-uri' in your ".
|
"\"http:// or https://\")\nin your custom config file.\nRefer to ".
|
||||||
"custom config file. Refer to 'default.conf.php' for documentation ".
|
"'default.conf.php' for documentation on configuration options.\n");
|
||||||
"on configuration options.\n");
|
return;
|
||||||
return;
|
}
|
||||||
} else {
|
if (preg_match('/.*\/$/', $host)) {
|
||||||
self::write(" okay phabricator.base-uri\n");
|
self::write(" okay phabricator.base-uri\n");
|
||||||
|
} else {
|
||||||
|
self::writeFailure();
|
||||||
|
self::write(
|
||||||
|
"You must add a trailing slash at the end of the host\n(e.g.: ".
|
||||||
|
"\"http://phabricator.example.com/ instead of ".
|
||||||
|
"http://phabricator.example.com\")\nin your custom config file.".
|
||||||
|
"\nRefer to 'default.conf.php' for documentation on configuration ".
|
||||||
|
"options.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self::write("[OKAY] Basic configuration OKAY\n");
|
self::write("[OKAY] Basic configuration OKAY\n");
|
||||||
|
@ -426,4 +436,4 @@ class PhabricatorSetup {
|
||||||
"\n\n");
|
"\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -4,8 +4,6 @@
|
||||||
* @generated
|
* @generated
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
phutil_require_module('phabricator', 'infrastructure/env');
|
phutil_require_module('phabricator', 'infrastructure/env');
|
||||||
phutil_require_module('phabricator', 'infrastructure/setup/sql');
|
phutil_require_module('phabricator', 'infrastructure/setup/sql');
|
||||||
phutil_require_module('phabricator', 'storage/connection/mysql');
|
phutil_require_module('phabricator', 'storage/connection/mysql');
|
||||||
|
@ -14,7 +12,7 @@ phutil_require_module('phabricator', 'storage/queryfx');
|
||||||
phutil_require_module('phutil', 'filesystem');
|
phutil_require_module('phutil', 'filesystem');
|
||||||
phutil_require_module('phutil', 'future/exec');
|
phutil_require_module('phutil', 'future/exec');
|
||||||
phutil_require_module('phutil', 'moduleutils');
|
phutil_require_module('phutil', 'moduleutils');
|
||||||
|
phutil_require_module('phutil', 'parser/uri');
|
||||||
phutil_require_module('phutil', 'utils');
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
phutil_require_source('PhabricatorSetup.php');
|
||||||
phutil_require_source('PhabricatorSetup.php');
|
|
Loading…
Reference in a new issue