Commit graph

144 commits

Author SHA1 Message Date
Oliver Blanthorn
3b38f093b7
Merge pull request #2194 from mozbugbox/bind-completion
Binding completion
2020-02-28 21:10:04 +00:00
Oliver Blanthorn
c6e1ed8c5c
Add completions to composite 2020-02-27 13:53:06 +00:00
mozbug
37b8b99999 Add completions for key bindings 2020-02-27 21:31:41 +08:00
Oliver Blanthorn
1cb143abea
Fix #1258: add apropos command 2019-11-06 11:26:52 +00:00
Jakub Okoński
dd422cd136 Enable some low-hanging TypeScript strictness options 2019-10-20 13:09:21 +02:00
rektrex
40c767a9a5 add extoptions excmd 2019-09-14 02:54:50 +05:30
Colin Caine
0faf4be41a
This allowed malicious web pages to send artificial key events to
the  parsers for  all modes  except the  command line  (which has
always been protected inside an iframe).

If the native  messenger was not installed, the bug  could not be
exploited  for  any more  than  nuisance  attacks (closing  tabs,
quitting Firefox,  etc.). If the native  messenger was installed,
an attack using the mpv hint  mode (bound to `;v` by default) and
a specially crafted link would  allow an attacker to execute some
commands  in the  user's shell.  Due  to the  way hyperlinks  are
encoded,  it  would  require  more  cunning  than  the  Tridactyl
developers possess to usefully exploit as it is difficult to pass
arguments to commands.

This  did mean  that the  standard output  of mpv  (including the
attacker's URL) was  also available to an attacker  via pipes. We
are not  aware of any way  to abuse that with  commonly installed
utilities.

We are unaware of any pages exploiting this in the wild.

Nevertheless, this security regression  should not have happened.
A short incident report follows:

These  checks were  accidentally  removed when  key handling  was
rewritten in  September 2018. The PR  was reviewed, but it  was a
large PR and the regression was missed by the reviewers.

We became aware of the regression after a question in our support
chat prompted  @glacambre to check  on exactly how we  were using
`isTrusted` and they realised that we weren't using it any more.

We  will  shortly  introduce  automated testing  to  check  these
security properties that we rely on.

We will  consider adding a  check to continuous  integration that
flags any change  to files containing security  relevant code for
more detailed review.

Affected versions: - Tridactyl 1.14.0 - 1.14.10, 1.15.0.

Mitigation:

- Update to Tridactyl 1.16.0+ or 1.14.13+

- If  updating is  unfeasible, we  recommend removing  the native
messenger by running `:! pwd` in Tridactyl and then deleting that
directory from your filesystem.

-  If  you've  thought  of   a  clever  exploit,  please  contact
bovine3dom or cmcaine privately on Matrix or by email.
2019-07-02 16:45:31 +01:00
Colin Caine
98c107a2d2 Fix #1656
Keyseq is adding a count to the end of response.exstr. Stop that everywhere in exmode.
2019-06-04 18:10:45 +01:00
Colin Caine
bf74b14a78 Don't send ex.* excmds around the houses
Previously they went on a magical mystery tour with up to
four stops on the way.

Now they take one synchronous step and are done, hopefully
avoiding race conditions.
2019-06-04 10:29:12 +01:00
Saul Reynolds-Haertle
2e5fdfb63c Run excmds in content. 2019-04-21 02:42:59 -07:00
glacambre
973ec07f92
Remove BGSELF
BGSELF was a hack that I used when implementing ex commands for the
command line. It consisted of having .excmds_background.generated.ts
import itself as BGSELF in order to dynamically add commands to it. This
let us define excmds in other files while not changing anything in
parsers/exmode.ts.

This was awful so I decided to remove it. This required performing the
following changes:
- Moving text.* and ex.* command definitions to their own files where
  they have zero side effects. While this was easy for text commands, ex
  commands rely a lot on side effects. In order to work around this,
  lib/commandline_cmds exports a single function, getCommandlineFns(),
  which expects an object representing the commandline's state as
  parameter.
- In the background script, import our side effect free files and wrap
  them in proxys that will send "commandline_cmd" and "editorfn_content"
  messages to tabs when needed.
- In the content script, add a listener that will either execute an
  editor function or forward it to the command line when it receives an
  "editorfn_content" message.
- In the commandline script, add a listener that will execute exmode
  commands.
2019-04-21 10:33:05 +02:00
glacambre
51f88f51c9
Fix errors found by LGTM
https://lgtm.com/projects/g/tridactyl/tridactyl/overview/
2019-04-17 07:18:18 +02:00
glacambre
923f9caf92
TSLint: enable no-unused-declaration rule
This rule requires adding a new set of rules, tslint-etc.
no-unused-declaration used to be available in tslint:recommended but was
deprecated when --noUnusedVariables was added to typescript. The problem
with using TypeScript's --noUnusedVariables is that it turns unused
declarations into an error and prevents compilation, which isn't fun
when you're just prototyping things.
2019-04-16 08:30:31 +02:00
glacambre
2b11d1d464
TSLint: re-enable prefer-const rule 2019-04-14 08:01:26 +02:00
glacambre
0a8c3cd2f6
TSLint: re-enable whitespace rule 2019-04-12 05:54:31 +02:00
glacambre
ff8f313aa5
Turn double-equals into triple-equals
See https://github.com/tridactyl/tridactyl/pull/1451
2019-04-10 12:28:47 +02:00
glacambre
bd65146ca8
TSLint: re-enable no-unnecessary-initializer rule 2019-04-10 06:47:46 +02:00
glacambre
1b7c4f2052
TSLint: re-enable no-useless-cast rule 2019-04-04 07:09:44 +02:00
Oliver Blanthorn
4d3b86f5ee
Merge branch 'remove_commandline_background' 2019-03-12 15:15:58 +00:00
glacambre
5dd1ec3a74
completions: Make sure completion computation has ended before resizeArea
Before this commit, Tridactyl had a bug where resizeArea could be called
before completion computation had ended, which resulted in completions
pushing the input field out of the viewport (easy way to reproduce this:
open a lot of tabs and press `b` to open buffer completions).
This happened because for some of the completion sources, `filter`
returned before completion computation had actually ended. This is fixed
by making sure that filter() (and all underlying calls to updateOptions,
onInput, updateChain...) return a promise that will only be resolved
once completion computation has actually ended.
2019-03-05 07:45:07 +01:00
glacambre
4e6e9aadac
Resize command line only once per available completion source
One of the problems of the command line was that it made a resizeArea()
call for each enabled completion, no matter whether its status was
"hidden" or "normal". This was a problem because a resizeArea call
results in 2 cross-script messages: a "show" and a "focus" message. This
means that for each keystroke, we sent 28 messages. This commit fixes
that thanks to modifications in multiple files:

- commandline_frame.ts: Stop accumulating event listeners on resizeArea
  calls. Make sure completion sources actually need a refresh before
  calling resizeArea().
- completions.ts: Add logic to know whether a completion source needs a
  refresh or not.
- {Rss,Sessions,Tab,TabAll,Window}.ts: Make sure that completions are
  actually needed before computing them.

This seems to make opening the command line slightly faster for me,
although I can't tell if this is placebo or not.
2019-03-01 06:18:07 +01:00
glacambre
bdd3e04199
Implement deselect_completion ex command
Left unbound by default.
2019-02-28 18:27:21 +01:00
glacambre
85b3e33719
Remove commandline_background
This commit removes commandline_background.ts. I believe this is useful
because the only thing it did was provide recvExStr, which just
triggered a synthetic "onLine" event the only consumer of which was the
parser. Since we already used controller_background + acceptExCmd in
some places, it made sense to me to directly use controller_background +
acceptExCmd everywhere.
2019-02-26 08:41:19 +01:00
glacambre
f9fa447a24
Implement guiset completions 2019-02-23 16:17:05 +01:00
glacambre
f119a89ac5
commandline_frame.ts: Fix compile-time error
10cb692d72 broke the build bot by
introducing type incompatibilites. This is fixed by making sure .catch()
returns an array.
This enables removing the try/catch in the input event handler since
the await won't throw anymore.
2019-02-12 12:43:53 +01:00
glacambre
10cb692d72
commandline_frame.ts: Catch errors in refresh_completions
https://github.com/tridactyl/tridactyl/issues/1345 describes a problem
where completion computation fails and fills the command line with an
error message.
This commit doesn't make the underlying problem disappear but prevents
Tridactyl from spamming the command line.
2019-02-11 19:26:26 +01:00
glacambre
8f33350d21
commandline_frame.ts: update HISTORY_SEARCH_STRING when needed
https://github.com/tridactyl/tridactyl/issues/1329 describes a bug that
can be triggered with the following key presses:

:t<ArrowUp><ArrowDown><Backspace>w<ArrowUp>

This results in the commandline being filled with a command starting
with `t` rather than `w`. This is caused by not updating the
HISTORY_SEARCH_STRING variable on changes and is fixed by always
resetting it if the previous command did not call history().

Closes #1329.
2019-02-09 13:07:47 +01:00
glacambre
e098e48e44
commandline_frame.ts: Simplify completion-updating mechanism
https://github.com/tridactyl/tridactyl/issues/1295 reports that
sometimes, completions won't be offered for excmds even though they
should. This happened because of the following steps:

- A letter is pressed, triggering an "input" event which schedules
  completion computation
- <Space> is pressed, which doesn't trigger an "input" event since it's
  bound to an excmd. However, the excmd itself refreshes completions.
- The computation scheduled by the "input" event is run with the
  previous exstr, even though it isn't up to date anymore.

This is fixed by replacing all the complicated timeoutId checking with
exstr checking, which makes a lot more sense, is simpler and all around
better.

Closes #1295.
2019-02-05 05:22:48 +01:00
glacambre
3e78e2bcf9
Implement winclose and winclose completions
Winclose was already there but was much less useful (could only close
the current window). This commit enables closing other windows and
provides completions for it.

Related issue: https://github.com/tridactyl/tridactyl/issues/794.
2019-01-31 08:13:05 +01:00
Oliver Blanthorn
ba0dea0349
Merge branch 'make_find_faster' 2019-01-22 15:44:48 +00:00
glacambre
a353c51354
Impletment sessions completion
Sessions completion let us provide completions for the `:undo` ex
command, which can be useful if you need to restore an older tab.

Closes https://github.com/tridactyl/tridactyl/issues/1127.
2019-01-19 18:06:05 +01:00
Oliver Blanthorn
fba8087ef6
Disable find completion: it breaks stuff 2019-01-15 17:51:20 +00:00
Oliver Blanthorn
19e6cc4ca2
Re-enable commandline completions 2019-01-15 17:32:29 +00:00
Oliver Blanthorn
2ee47a9941
Merge branch 'master' into make_find_faster
Rebases are for people who understand how git works.
2019-01-15 17:09:16 +00:00
glacambre
be315ac967
Implement getrss completions 2018-12-27 11:05:47 +01:00
glacambre
55d6a1e0e6
commandline_frame.ts: stop using dirty hacks for completions
The previous code simulated an input event in order to trigger the input
event handler which recomputed completions. This was ok until delays
were added to the input event handlers in order to reduce the lag that
could happen when typing fast/keeping a key pressed. This delay also
affects completion computation on other actions, such as fillcmdline.

In order to remove this delay, we move completion computation out of the
event handler and directly call this functions everywhere we previously
triggered an input event.

This should help with https://github.com/tridactyl/tridactyl/issues/1242
2018-12-24 09:26:57 +01:00
glacambre
4a6305df47
Fix "tab" alias breaking completions
PR#1183 broke completions for users that had a tab -> buffer alias. This
is because having such an alias created a loop, which made
BufferCompletionSource throw errors when being instanciated, which
resulted in the activeCompletions array not being created.

This is fixed in two ways: first, a config updater is created in order
to remove the alias. Second, completions are instantiated in
try/catchs, which should hopefully prevent a faulty completion source
constructor from breaking every completion source.
2018-12-10 07:00:11 +01:00
glacambre
6e1e24b3d3
Fix 'clipboard yanksel' not working in commandline frame
Closes #1205.
2018-12-04 07:12:26 +01:00
Oliver Blanthorn
7e21d64025
Fix broken completions 2018-11-20 20:16:07 +00:00
glacambre
c412c8dad0
Rename buffers to tabs
Note: The CSS class names are kept as they were, see #1183 for more
information.
2018-11-19 18:35:37 +01:00
glacambre
8d9795a19b
commandline_frame.ts: Make sure activeCompletions is defined
This is a temporary fix for
https://github.com/tridactyl/tridactyl/issues/1167 . I couldn't find
where this issue might come from and since there are no reproduction
steps this will have to do.

I plan on modeling Tridactyl in TLA+ when I have time in order to find
out where our hard-to-reproduce bugs come from. Hopefully this bug will
be among them.

Closes #1167.
2018-11-13 18:35:11 +01:00
glacambre
cd55b6f0f8
Update documentation links
As cmcaine said in #1149, the help page links are currently broken
because typedoc tries to generate documentation for source files in the
`compiler/` directory. I just realized that before #1026, these files
were not referenced in any of the files in the `src` directory and this
is why typedoc ignored them. This change happened because I wanted to
type the metadata.

There are three possible solution to #1149.
- Go back to untyped metadata.
- Move the metadata types to Tridactyl's src directory on build.
- Update all links to the doc.

I believe having typed metadata is useful and I'd like to keep it that
way. Moving the metadata types to Tridactyl's src directory is certainly
doable but doesn't sound like the best idea to me, we're unnecessarily
copying files. Updating the links to the doc sounds reasonable as it's
only a one-time thing and so this is what this commit does in order to
close #1149.
2018-11-08 07:00:35 +01:00
glacambre
7b5f7ef298
Minor code cleanups
This commit makes error messages when the native messenger is
unavailable easier to read. Since they're easier to read, there's no
need for custom errors in setclip/getclip anymore, provided that the
errors they throw are correctly logged. In order to make sure of that,
we remove the try/catch in excmds.ts:clipboard(), which should let
errors bubble up as needed.

I also noticed that while {set,get}Clipboard relied on the command line
being focused in order to work, they didn't do that themselves and
instead expected their callers to have set things up. This didn't make
sense to me so I moved the focusing code inside of {set,get}Clipboard.

This was all done while chasing the elusive #1135 but probably doesn't
change anything about it.
2018-11-07 06:21:36 +01:00
glacambre
b30c68fa51
Fix commandline failing to insert spaces in middle of words
Before this commit, it was impossible to insert a space in the middle of
a word in the command line ; the space would always be inserted at its
end.
2018-11-06 02:19:34 +01:00
Oliver Blanthorn
d796f3bf14
Merge branch 'generic_cmdline' 2018-11-04 12:28:31 +00:00
glacambre
def94f795d
Document ex.* functions 2018-11-02 06:33:09 +01:00
glacambre
cfe5b5c597
commandline_frame.ts: Reset keyEvents
Before this commit, keyEvents was never reset. This caused weird issues
like control closing the commandline after a first ex command had been
accepted. We now reset keyEvents in two places ; when an ex command is
accepted (which could happen when inserting a completion, for example)
and when the command line is closed (which could be triggered by an
outside event).
2018-11-01 19:11:57 +01:00
glacambre
c0bffbd4e3
commandline_frame.ts: Remove unnecessary insert_completion_or_space fn 2018-11-01 18:43:59 +01:00
glacambre
00c01ec6ec
Enable rebinding keys in command line
We re-use the ex-command parser in order to enable rebinding keys in
command-line mode. Command-line manipulation is re-implemented using
previously-abstracter editor commands.
2018-10-31 08:16:58 +01:00
glacambre
a6a3e4ac2f
commandline_frame.ts: Try to get rid of input lag
We try to get rid of input lag by only starting completion computation
some time after the user stopped pressing letters. This should in theory
help with https://github.com/tridactyl/tridactyl/issues/1092 and close
https://github.com/tridactyl/tridactyl/issues/454 and
https://github.com/tridactyl/tridactyl/issues/229.
2018-10-24 22:08:24 +02:00