1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-31 08:58:20 +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; $version_note = null;
if (!$document) { if (!$document) {
$create_uri = '/phriction/edit/?slug='.$slug;
$page_content = if (PhrictionDocument::isProjectSlug($slug)) {
'<div class="phriction-content">'. $project = id(new PhabricatorProject())->loadOneWhere(
'<em>No content here!</em><br />'. 'phrictionSlug = %s',
'No document found at <tt>'.phutil_escape_html($slug).'</tt>. '. PhrictionDocument::getProjectSlugIdentifier($slug));
'You can <strong>'. if (!$project) {
phutil_render_tag( return new Aphront404Response();
'a', }
array( }
'href' => $create_uri, $create_uri = '/phriction/edit/?slug='.$slug;
), $create_sentence =
'create a new document').'</strong>.'. 'You can <strong>'.
'</div>'; phutil_render_tag(
$page_title = 'Page Not Found'; 'a',
array(
'href' => $create_uri,
),
'create a new document').
'</strong>.';
$button = phutil_render_tag( $button = phutil_render_tag(
'a', 'a',
array( array(
@ -72,6 +76,14 @@ final class PhrictionDocumentController
'class' => 'green button', 'class' => 'green button',
), ),
'Create Page'); '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; $buttons = $button;
} else { } else {
$version = $request->getInt('v'); $version = $request->getInt('v');

View file

@ -66,6 +66,14 @@ final class PhrictionEditController
if ($document) { if ($document) {
$content = id(new PhrictionContent())->load($document->getContentID()); $content = id(new PhrictionContent())->load($document->getContentID());
} else { } else {
if (PhrictionDocument::isProjectSlug($slug)) {
$project = id(new PhabricatorProject())->loadOneWhere(
'phrictionSlug = %s',
PhrictionDocument::getProjectSlugIdentifier($slug));
if (!$project) {
return new Aphront404Response();
}
}
$document = new PhrictionDocument(); $document = new PhrictionDocument();
$document->setSlug($slug); $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/editor/document');
phutil_require_module('phabricator', 'applications/phriction/storage/content'); phutil_require_module('phabricator', 'applications/phriction/storage/content');
phutil_require_module('phabricator', 'applications/phriction/storage/document'); 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/celerity/api');
phutil_require_module('phabricator', 'infrastructure/env'); phutil_require_module('phabricator', 'infrastructure/env');
phutil_require_module('phabricator', 'infrastructure/javelin/api'); phutil_require_module('phabricator', 'infrastructure/javelin/api');