1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-18 18:51:12 +01:00

Phriction - lock down /project/ wiki docs

Summary:
only show the blank, "create new" wiki page for the project if the project actually exists; only allow edit if the project actually exists.
Small wrinkle here is not checking if the project actually exists if the page already exists.

Test Plan:
- viewed a project wiki page
- viewed a prokect wiki page for a fake project and got a 404
- edited a project wiki page
- edited a project wiki page for a fake project and got a 404

Reviewers: epriestley, jacktrades

Reviewed By: epriestley

CC: aran, Koolvin

Maniphest Tasks: T1248

Differential Revision: https://secure.phabricator.com/D2506
This commit is contained in:
Bob Trahan 2012-05-20 08:54:25 -07:00
parent 3d5d8d0f11
commit a9000ea21c
3 changed files with 35 additions and 14 deletions

View file

@ -50,21 +50,25 @@ final class PhrictionDocumentController
$version_note = null;
if (!$document) {
$create_uri = '/phriction/edit/?slug='.$slug;
$page_content =
'<div class="phriction-content">'.
'<em>No content here!</em><br />'.
'No document found at <tt>'.phutil_escape_html($slug).'</tt>. '.
'You can <strong>'.
phutil_render_tag(
'a',
array(
'href' => $create_uri,
),
'create a new document').'</strong>.'.
'</div>';
$page_title = 'Page Not Found';
if (PhrictionDocument::isProjectSlug($slug)) {
$project = id(new PhabricatorProject())->loadOneWhere(
'phrictionSlug = %s',
PhrictionDocument::getProjectSlugIdentifier($slug));
if (!$project) {
return new Aphront404Response();
}
}
$create_uri = '/phriction/edit/?slug='.$slug;
$create_sentence =
'You can <strong>'.
phutil_render_tag(
'a',
array(
'href' => $create_uri,
),
'create a new document').
'</strong>.';
$button = phutil_render_tag(
'a',
array(
@ -72,6 +76,14 @@ final class PhrictionDocumentController
'class' => 'green button',
),
'Create Page');
$page_content =
'<div class="phriction-content">'.
'<em>No content here!</em><br />'.
'No document found at <tt>'.phutil_escape_html($slug).'</tt>. '.
$create_sentence.
'</div>';
$page_title = 'Page Not Found';
$buttons = $button;
} else {
$version = $request->getInt('v');

View file

@ -66,6 +66,14 @@ final class PhrictionEditController
if ($document) {
$content = id(new PhrictionContent())->load($document->getContentID());
} else {
if (PhrictionDocument::isProjectSlug($slug)) {
$project = id(new PhabricatorProject())->loadOneWhere(
'phrictionSlug = %s',
PhrictionDocument::getProjectSlugIdentifier($slug));
if (!$project) {
return new Aphront404Response();
}
}
$document = new PhrictionDocument();
$document->setSlug($slug);

View file

@ -13,6 +13,7 @@ phutil_require_module('phabricator', 'applications/phriction/controller/base');
phutil_require_module('phabricator', 'applications/phriction/editor/document');
phutil_require_module('phabricator', 'applications/phriction/storage/content');
phutil_require_module('phabricator', 'applications/phriction/storage/document');
phutil_require_module('phabricator', 'applications/project/storage/project');
phutil_require_module('phabricator', 'infrastructure/celerity/api');
phutil_require_module('phabricator', 'infrastructure/env');
phutil_require_module('phabricator', 'infrastructure/javelin/api');