1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +01:00

Fix is_absolute test in markup

Summary:
See Q59. Fixes rP935d7120ee32.

Call sites should be happy to use PhutilURI when possible.

Test Plan: visit any Repository page. Before - exception, now - data.

Reviewers: O1 Blessed Committers!, valerio.bozzolan

Reviewed By: valerio.bozzolan

Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D25139
This commit is contained in:
Aviv Eyal 2023-04-28 03:41:20 -07:00
parent b56d86e48d
commit 74dfe6f971

View file

@ -77,9 +77,27 @@ function phabricator_form(PhabricatorUser $user, $attributes, $content) {
$is_post = (strcasecmp($http_method, 'POST') === 0);
$http_action = idx($attributes, 'action');
$is_absolute_uri = 0;
if (phutil_nonempty_string($http_action)) {
if ($http_action === null) {
// Not sure what this is.
$is_absolute_uri = false;
} else if ($http_action instanceof PhutilURI) {
// This is the happy path, I think
// For now, this is close enough - I suspect we'll stay with "https" schema
// for the rest of eternity.
$protocol = $http_action->getProtocol();
$is_absolute_uri = ($protocol == 'http' || $protocol == 'https');
} else if (is_string($http_action)) {
// Also good path?
$is_absolute_uri = preg_match('#^(https?:|//)#', $http_action);
} else {
throw new Exception(
pht(
'Unexpected object type provided as `action` - %s',
gettype($http_action)));
}
if ($is_post) {