@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix Phriction document previews for the root document ("/") with Apache option "MergeSlashes On"

Summary:
Ref T13662. I ran into this while trying to reproduce the mention issue discussed there.

Currently, the root document (with slug "/") attempts to preview using the URI `/phriction/preview//` (with two `//` at the end). This is collapsed into "/phriction/preview/" by Apache if "MergeSlashes On" is configured, which is the default behavior. The route then 404s.

Instead, just use "/phriction/preview/?slug=/" so this endpoint functions properly regardless of the "MergeSlashes" configuration.

Test Plan:
- Configured Apache with "MergeSlashes On" (which is the default behavior).
- Tried to preview a content edit of the root document in Phriction, which didn't work and generated 404s for "/phriction/preview//" in the console log.
- Applied patch.
- Previwed content in Phriction (which now worked properly).
- Accessed `/a//b///c////` and similar with "MergeSlashes On" and "MergeSlashes Off", confirmed that this option controls whether PHP receives a URI with or without merged slashes in "__path__" after rewriting.

Reviewers: 0

Reviewed By: 0

Maniphest Tasks: T13662

Differential Revision: https://secure.phabricator.com/D21708

+11 -3
+1 -1
src/applications/phriction/application/PhabricatorPhrictionApplication.php
··· 61 61 'new/' => 'PhrictionNewController', 62 62 'move/(?P<id>[1-9]\d*)/' => 'PhrictionMoveController', 63 63 64 - 'preview/(?P<slug>.*/)' => 'PhrictionMarkupPreviewController', 64 + 'preview/' => 'PhrictionMarkupPreviewController', 65 65 'diff/(?P<id>[1-9]\d*)/' => 'PhrictionDiffController', 66 66 67 67 $this->getEditRoutePattern('document/edit/')
+9 -1
src/applications/phriction/controller/PhrictionEditController.php
··· 316 316 ->setBackground(PHUIObjectBoxView::WHITE_CONFIG) 317 317 ->setForm($form); 318 318 319 + $preview_uri = '/phriction/preview/'; 320 + $preview_uri = new PhutilURI( 321 + $preview_uri, 322 + array( 323 + 'slug' => $document->getSlug(), 324 + )); 325 + $preview_uri = phutil_string_cast($preview_uri); 326 + 319 327 $preview = id(new PHUIRemarkupPreviewPanel()) 320 328 ->setHeader($content->getTitle()) 321 - ->setPreviewURI('/phriction/preview/'.$document->getSlug()) 329 + ->setPreviewURI($preview_uri) 322 330 ->setControlID('document-textarea') 323 331 ->setPreviewType(PHUIRemarkupPreviewPanel::DOCUMENT); 324 332
+1 -1
src/applications/phriction/controller/PhrictionMarkupPreviewController.php
··· 8 8 $viewer = $request->getUser(); 9 9 10 10 $text = $request->getStr('text'); 11 - $slug = $request->getURIData('slug'); 11 + $slug = $request->getStr('slug'); 12 12 13 13 $output = PhabricatorMarkupEngine::renderOneObject( 14 14 id(new PhabricatorMarkupOneOff())