@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.

Handle symbolic commit names better in Diffusion

Summary: We now allow symbolic commits, so let them through the pipeline.

Test Plan: {F10571}

Reviewers: davidreuss, btrahan, vrana

Reviewed By: davidreuss

CC: aran

Maniphest Tasks: T1130

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

+33 -6
+16 -5
src/applications/diffusion/request/base/DiffusionRequest.php
··· 351 351 $path = "{$branch}{$path}"; 352 352 353 353 if (strlen($commit)) { 354 + $commit = str_replace('$', '$$', $commit); 354 355 $commit = ';'.phutil_escape_uri($commit); 355 356 } 356 357 ··· 471 472 // Consume the back part of the URI, up to the first "$". Use a negative 472 473 // lookbehind to prevent matching '$$'. We double the '$' symbol when 473 474 // encoding so that files with names like "money/$100" will survive. 474 - if (preg_match('@(?<![$])[$]([\d-]+)$@', $blob, $matches)) { 475 + $pattern = '@(?:(?:^|[^$])(?:[$][$])*)[$]([\d-]+)$@'; 476 + if (preg_match($pattern, $blob, $matches)) { 475 477 $result['line'] = $matches[1]; 476 478 $blob = substr($blob, 0, -(strlen($matches[1]) + 1)); 477 479 } 478 480 479 - // Consume the commit name, stopping on ';;'. 480 - if (preg_match('@(?<!;);([a-z0-9]+)$@', $blob, $matches)) { 481 + // We've consumed the line number if it exists, so unescape "$" in the 482 + // rest of the string. 483 + $blob = str_replace('$$', '$', $blob); 484 + 485 + // Consume the commit name, stopping on ';;'. We allow any character to 486 + // appear in commits names, as they can sometimes be symbolic names (like 487 + // tag names or refs). 488 + if (preg_match('@(?:(?:^|[^;])(?:;;)*);([^;].*)$@', $blob, $matches)) { 481 489 $result['commit'] = $matches[1]; 482 490 $blob = substr($blob, 0, -(strlen($matches[1]) + 1)); 483 491 } 484 492 485 - // Un-double our delimiter characters. 493 + // We've consumed the commit if it exists, so unescape ";" in the rest 494 + // of the string. 495 + $blob = str_replace(';;', ';', $blob); 496 + 486 497 if (strlen($blob)) { 487 - $result['path'] = str_replace(array(';;', '$$'), array(';', '$'), $blob); 498 + $result['path'] = $blob; 488 499 } 489 500 490 501 $parts = explode('/', $result['path']);
+16
src/applications/diffusion/request/base/__tests__/DiffusionURITestCase.php
··· 39 39 'a%252Fb/' => array( 40 40 'branch' => 'a/b', 41 41 ), 42 + 'branch/path/;Version-1_0_0' => array( 43 + 'branch' => 'branch', 44 + 'path' => 'path/', 45 + 'commit' => 'Version-1_0_0', 46 + ), 47 + 'branch/path/;$$moneytag$$' => array( 48 + 'branch' => 'branch', 49 + 'path' => 'path/', 50 + 'commit' => '$moneytag$', 51 + ), 52 + 'branch/path/semicolon;;;;;$$;;semicolon;;$$$$$100' => array( 53 + 'branch' => 'branch', 54 + 'path' => 'path/semicolon;;', 55 + 'commit' => '$;;semicolon;;$$', 56 + 'line' => '100', 57 + ), 42 58 ); 43 59 44 60 foreach ($map as $input => $expect) {
+1 -1
src/applications/diffusion/view/taglist/DiffusionTagListView.php
··· 62 62 'href' => $drequest->generateURI( 63 63 array( 64 64 'action' => 'browse', 65 - 'commit' => $tag->getCommitIdentifier(), 65 + 'commit' => $tag->getName(), 66 66 )), 67 67 ), 68 68 phutil_escape_html($tag->getName()));