1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-25 16:22:43 +01:00

Trim and URI encode symbol names before building URIs from them

Summary:
Fixes T13437. This URI construction was just missing URI encoding.

Also, trim the symbol because my test case ended up catching "#define\n" as symbol text.

Test Plan:
  - Configured a repository to have PHP symbols.
  - Touched a ".php" file with "#define" in it.
  - Diffed the change.
  - Command-clicked "#define" in the UI, in Safari/MacOS, to jump to the definition.
    - Before: taken to a nonsense page where "#define" became an anchor.
    - After: taken to symbol search for "#define".

Maniphest Tasks: T13437

Differential Revision: https://secure.phabricator.com/D20876
This commit is contained in:
epriestley 2019-10-29 09:37:22 -07:00
parent 4a53fc339e
commit e1da1d86d6
2 changed files with 19 additions and 10 deletions

View file

@ -12,7 +12,7 @@ return array(
'core.pkg.css' => '686ae87c',
'core.pkg.js' => '6e5c894f',
'differential.pkg.css' => '607c84be',
'differential.pkg.js' => 'a0212a0b',
'differential.pkg.js' => '1b97518d',
'diffusion.pkg.css' => '42c75c37',
'diffusion.pkg.js' => 'a98c0bf7',
'maniphest.pkg.css' => '35995d6d',
@ -428,7 +428,7 @@ return array(
'rsrc/js/application/releeph/releeph-preview-branch.js' => '75184d68',
'rsrc/js/application/releeph/releeph-request-state-change.js' => '9f081f05',
'rsrc/js/application/releeph/releeph-request-typeahead.js' => 'aa3a100c',
'rsrc/js/application/repository/repository-crossreference.js' => 'c15122b4',
'rsrc/js/application/repository/repository-crossreference.js' => '1c95ea63',
'rsrc/js/application/search/behavior-reorder-profile-menu-items.js' => 'e5bdb730',
'rsrc/js/application/search/behavior-reorder-queries.js' => 'b86f297f',
'rsrc/js/application/transactions/behavior-comment-actions.js' => '4dffaeb2',
@ -682,7 +682,7 @@ return array(
'javelin-behavior-reorder-applications' => 'aa371860',
'javelin-behavior-reorder-columns' => '8ac32fd9',
'javelin-behavior-reorder-profile-menu-items' => 'e5bdb730',
'javelin-behavior-repository-crossreference' => 'c15122b4',
'javelin-behavior-repository-crossreference' => '1c95ea63',
'javelin-behavior-scrollbar' => '92388bae',
'javelin-behavior-search-reorder-queries' => 'b86f297f',
'javelin-behavior-select-content' => 'e8240b50',
@ -1034,6 +1034,12 @@ return array(
'javelin-install',
'javelin-util',
),
'1c95ea63' => array(
'javelin-behavior',
'javelin-dom',
'javelin-stratcom',
'javelin-uri',
),
'1cab0e9a' => array(
'javelin-behavior',
'javelin-dom',
@ -1977,12 +1983,6 @@ return array(
'c03f2fb4' => array(
'javelin-install',
),
'c15122b4' => array(
'javelin-behavior',
'javelin-dom',
'javelin-stratcom',
'javelin-uri',
),
'c2c500a7' => array(
'javelin-install',
'javelin-dom',

View file

@ -152,7 +152,16 @@ JX.behavior('repository-crossreference', function(config, statics) {
query.char = char;
}
var uri = JX.$U('/diffusion/symbol/' + symbol + '/');
var uri_symbol = symbol;
// In some cases, lexers may include whitespace in symbol tags. Trim it,
// since symbols with semantic whitespace aren't supported.
uri_symbol = uri_symbol.trim();
// See T13437. Symbols like "#define" need to be encoded.
uri_symbol = encodeURIComponent(uri_symbol);
var uri = JX.$U('/diffusion/symbol/' + uri_symbol + '/');
uri.addQueryParams(query);
window.open(uri.toString());