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

Use PhutilBugtraqParser in Phabricator

Summary: Fixes T3840. Depends on D7021. See task for discussion. Also improved some config/help stuff.

Test Plan: See screenshot.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T3840

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

+25 -54
-1
src/applications/config/controller/PhabricatorConfigEditController.php
··· 486 486 if (is_array($value)) { 487 487 $value = implode("\n", $value); 488 488 } 489 - $value = phutil_escape_html_newlines($value); 490 489 } 491 490 492 491 $table[] = hsprintf(
+1
src/applications/diffusion/config/PhabricatorDiffusionConfigOptions.php
··· 79 79 array('/[Ii]ssues?:?(\s*,?\s*#\d+)+/', '/(\d+)/'), 80 80 pht('Issue #123, #456')) 81 81 ->addExample(array('/(?<!#)\b(T[1-9]\d*)\b/'), pht('Task T123')) 82 + ->addExample('/[A-Z]{2,}-\d+/', pht('JIRA-1234')) 82 83 ->setDescription(pht( 83 84 'Regular expression to link external bug tracker. See '. 84 85 'http://tortoisesvn.net/docs/release/TortoiseSVN_en/'.
+24 -1
src/applications/diffusion/controller/DiffusionCommitController.php
··· 106 106 $message = $commit_data->getCommitMessage(); 107 107 108 108 $revision = $commit->getCommitIdentifier(); 109 - $message = $repository->linkBugtraq($message, $revision); 109 + $message = $this->linkBugtraq($message); 110 110 111 111 $message = $engine->markupText($message); 112 112 ··· 997 997 } 998 998 999 999 return $view; 1000 + } 1001 + 1002 + private function linkBugtraq($corpus) { 1003 + $url = PhabricatorEnv::getEnvConfig('bugtraq.url'); 1004 + if (!strlen($url)) { 1005 + return $corpus; 1006 + } 1007 + 1008 + $regexes = PhabricatorEnv::getEnvConfig('bugtraq.logregex'); 1009 + if (!$regexes) { 1010 + return $corpus; 1011 + } 1012 + 1013 + $parser = id(new PhutilBugtraqParser()) 1014 + ->setBugtraqPattern("[[ {$url} | %BUGID% ]]") 1015 + ->setBugtraqCaptureExpression(array_shift($regexes)); 1016 + 1017 + $select = array_shift($regexes); 1018 + if ($select) { 1019 + $parser->setBugtraqSelectExpression($select); 1020 + } 1021 + 1022 + return $parser->processCorpus($corpus); 1000 1023 } 1001 1024 1002 1025 }
-52
src/applications/repository/storage/PhabricatorRepository.php
··· 692 692 } 693 693 694 694 695 - /** 696 - * Link external bug tracking system if defined. 697 - * 698 - * @param string Plain text. 699 - * @param string Commit identifier. 700 - * @return string Remarkup 701 - */ 702 - public function linkBugtraq($message, $revision = null) { 703 - $bugtraq_url = PhabricatorEnv::getEnvConfig('bugtraq.url'); 704 - list($bugtraq_re, $id_re) = 705 - PhabricatorEnv::getEnvConfig('bugtraq.logregex') + 706 - array('', ''); 707 - 708 - switch ($this->getVersionControlSystem()) { 709 - case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: 710 - // TODO: Get bugtraq:logregex and bugtraq:url from SVN properties. 711 - break; 712 - } 713 - 714 - if (!$bugtraq_url || $bugtraq_re == '') { 715 - return $message; 716 - } 717 - 718 - $matches = null; 719 - $flags = PREG_SET_ORDER | PREG_OFFSET_CAPTURE; 720 - preg_match_all($bugtraq_re, $message, $matches, $flags); 721 - foreach ($matches as $match) { 722 - list($all, $all_offset) = array_shift($match); 723 - 724 - if ($id_re != '') { 725 - // Match substrings with bug IDs 726 - preg_match_all($id_re, $all, $match, PREG_OFFSET_CAPTURE); 727 - list(, $match) = $match; 728 - } else { 729 - $all_offset = 0; 730 - } 731 - 732 - $match = array_reverse($match); 733 - foreach ($match as $val) { 734 - list($s, $offset) = $val; 735 - $message = substr_replace( 736 - $message, 737 - '[[ '.str_replace('%BUGID%', $s, $bugtraq_url).' | '.$s.' ]]', 738 - $offset + $all_offset, 739 - strlen($s)); 740 - } 741 - } 742 - 743 - return $message; 744 - } 745 - 746 - 747 695 /* -( PhabricatorPolicyInterface )----------------------------------------- */ 748 696 749 697