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

Prevent copying Harbormaster build log line numbers with CSS psuedocontent instead of ZWS

Summary:
Depends on D19165. Ref T13088. Currently, in other applications, we use Zero Width Spaces and Javascript "copy" listeners to prevent line numbers from being copied. This isn't terribly elegant.

Modern browsers support a second approach: using psuedo-elements with `content`. Try this in Harbormaster since it's conceptually cleaner, at least. One immediate drawback is that Command-F can't find this text either.

Test Plan: In Safari, Chrome and Firefox, highlighted ranges of lines and copy/pasted text. Got just text (no line numbers) in all cases.

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13088

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

+28 -11
+10 -10
resources/celerity/map.php
··· 78 78 'rsrc/css/application/feed/feed.css' => 'ecd4ec57', 79 79 'rsrc/css/application/files/global-drag-and-drop.css' => 'b556a948', 80 80 'rsrc/css/application/flag/flag.css' => 'bba8f811', 81 - 'rsrc/css/application/harbormaster/harbormaster.css' => '2999ccaa', 81 + 'rsrc/css/application/harbormaster/harbormaster.css' => 'cd73d427', 82 82 'rsrc/css/application/herald/herald-test.css' => 'a52e323e', 83 83 'rsrc/css/application/herald/herald.css' => 'cd8d0134', 84 84 'rsrc/css/application/maniphest/report.css' => '9b9580b7', ··· 495 495 'rsrc/js/core/behavior-keyboard-pager.js' => 'a8da01f0', 496 496 'rsrc/js/core/behavior-keyboard-shortcuts.js' => '01fca1f0', 497 497 'rsrc/js/core/behavior-lightbox-attachments.js' => 'e31fad01', 498 - 'rsrc/js/core/behavior-line-linker.js' => 'c479ac01', 498 + 'rsrc/js/core/behavior-line-linker.js' => 'a9b946f8', 499 499 'rsrc/js/core/behavior-more.js' => 'a80d0378', 500 500 'rsrc/js/core/behavior-object-selector.js' => '77c1f0b0', 501 501 'rsrc/js/core/behavior-oncopy.js' => '2926fff2', ··· 579 579 'font-fontawesome' => 'e838e088', 580 580 'font-lato' => 'c7ccd872', 581 581 'global-drag-and-drop-css' => 'b556a948', 582 - 'harbormaster-css' => '2999ccaa', 582 + 'harbormaster-css' => 'cd73d427', 583 583 'herald-css' => 'cd8d0134', 584 584 'herald-rule-editor' => 'dca75c0e', 585 585 'herald-test-css' => 'a52e323e', ··· 658 658 'javelin-behavior-phabricator-gesture-example' => '558829c2', 659 659 'javelin-behavior-phabricator-keyboard-pager' => 'a8da01f0', 660 660 'javelin-behavior-phabricator-keyboard-shortcuts' => '01fca1f0', 661 - 'javelin-behavior-phabricator-line-linker' => 'c479ac01', 661 + 'javelin-behavior-phabricator-line-linker' => 'a9b946f8', 662 662 'javelin-behavior-phabricator-nav' => '836f966d', 663 663 'javelin-behavior-phabricator-notification-example' => '8ce821c5', 664 664 'javelin-behavior-phabricator-object-selector' => '77c1f0b0', ··· 1743 1743 'javelin-uri', 1744 1744 'phabricator-keyboard-shortcut', 1745 1745 ), 1746 + 'a9b946f8' => array( 1747 + 'javelin-behavior', 1748 + 'javelin-stratcom', 1749 + 'javelin-dom', 1750 + 'javelin-history', 1751 + ), 1746 1752 'a9f88de2' => array( 1747 1753 'javelin-behavior', 1748 1754 'javelin-dom', ··· 1930 1936 'javelin-behavior-device', 1931 1937 'javelin-stratcom', 1932 1938 'phabricator-tooltip', 1933 - ), 1934 - 'c479ac01' => array( 1935 - 'javelin-behavior', 1936 - 'javelin-stratcom', 1937 - 'javelin-dom', 1938 - 'javelin-history', 1939 1939 ), 1940 1940 'c587b80f' => array( 1941 1941 'javelin-install',
+2 -1
src/applications/harbormaster/controller/HarbormasterBuildLogRenderController.php
··· 369 369 'a', 370 370 array( 371 371 'href' => $uri.'$'.$display_line, 372 + 'data-n' => $display_line, 372 373 ), 373 - $display_line); 374 + ''); 374 375 375 376 $line_cell = phutil_tag('th', array(), $display_line); 376 377 $text_cell = phutil_tag('td', array(), $display_text);
+6
webroot/rsrc/css/application/harbormaster/harbormaster.css
··· 48 48 user-select: none; 49 49 } 50 50 51 + .harbormaster-log-table > tbody > tr > th a::before { 52 + /* Render the line numbers into the document using a pseudo-element so that 53 + the text is not copied. */ 54 + content: attr(data-n); 55 + } 56 + 51 57 .harbormaster-log-table > tbody > tr > th a { 52 58 display: block; 53 59 color: {$darkbluetext};
+10
webroot/rsrc/js/core/behavior-line-linker.js
··· 21 21 22 22 function getRowNumber(tr) { 23 23 var th = tr.firstChild; 24 + 25 + // If the "<th />" tag contains an "<a />" with "data-n" that we're using 26 + // to prevent copy/paste of line numbers, use that. 27 + if (th.firstChild) { 28 + var line = th.firstChild.getAttribute('data-n'); 29 + if (line) { 30 + return line; 31 + } 32 + } 33 + 24 34 return +(th.textContent || th.innerText); 25 35 } 26 36