Page MenuHomePhabricator

Unable to Open in External Editor when using custom protocols
Closed, ResolvedPublic

Description

Original Ticket:


Recently the IntelliJ IDEA and PhpStorm has added support for custom protocol handlers (the idea:// and phpstorm:// respectively) in their OSX versions. Can they be added to default allowed protocol list in uri.allowed-editor-protocols setting?

Phabricator_PhpStormEditorSupport.png (555×1 px, 104 KB)

Related issue: http://youtrack.jetbrains.com/issue/IDEA-65879

Event Timeline

aik099 raised the priority of this task from to Needs Triage.
aik099 updated the task description. (Show Details)
aik099 added projects: Diffusion, Audit.
aik099 updated the task description. (Show Details)
aik099 added a subscriber: aik099.

As advised I've tried to change configuration variable value, but got this error:

This configuration is locked and can not be edited from the web interface. Use `./bin/config` in `phabricator/` to edit it.

Problem is, that I don't know how to set multi-line configuration value from command-line.

I recommend automatically opening configured system editor (e.g. from $EDITOR env variable) when value of configuration variable wasn't given to ./bin/config set variable_name command.

I've managed to set new value from command line using this command:

./bin/config set uri.allowed-editor-protocols '{"http":true, "https":true, "txmt":true, "mvim":true, "vim":true, "subl":true, "emacs":true, "editor":true, "phpstorm":true, "idea":true}'

Changing configuration allowed to save my new editor in Display Preferences. However when click on "Open in Editor" link in "View Options" a file on a commit page I get error dialog (url http://.../help/editorprotocol/):

Unsupported Editor Protocol

Your configured editor URI uses an unsupported protocol. Change your settings to use a supported protocol, or ask your administrator to add support for the chosen protocol by configuring: uri.allowed-editor-protocols

This sounds like a bug. I've added custom editor and validation passed there and now I'm warned that editor turns out not to be valid at all.

I think it should maybe be:

./bin/config set uri.allowed-editor-protocols '["http", "https", "txmt", "mvim", "vim", "subl", "emacs", "editor", "phpstorm", "idea"]'

instead?

Nope, @hach-que. Your command gives following error:

Usage Exception: Option 'uri.allowed-editor-protocols' must be a set, but array contains values other than 'true'.

What specifically are you setting in your Display Preferences under "Editor"?

This line phpstorm://open?file=%f&line=%l as seen on screenshot I've originally attached to a task.

chad claimed this task.

Ah, nevermind. I can't reproduce this, I'm able to set new values (using your examples), restart the server, and they appear as options. Did you restart your server? We should now tell you to restart when config values change, but that is a more recent feature, so your instance might not have it yet.

Yes, I did restarted the server. As I said I have 2 problems in one:

  1. I wasn't able to change editor due not allowed protocol, which I eventually overcame by changing allowed protocols from command line
  2. The "View in Editor" link redirected me to error page about misconfigured editor - that I wasn't able to solve

Here is the link I've mentioned:

Phabricator_OpenInEditor_Error.png (442×430 px, 41 KB)

chad renamed this task from Add PhpStorm as one of possible editors to Unable to Open in External Editor when using custom protocols.Sep 16 2014, 3:37 PM
chad reopened this task as Open.
chad triaged this task as Normal priority.
chad updated the task description. (Show Details)

And original subject was to add the "idea" and "phpstorm" as allowed editor protocols as well.

When I've tried to add them myself I've encountered the error I also reported in this task.

We're not interested in adding more protocols, which is why it's extendible. But, we should obviously resolve this bugs!

We're not interested in adding more protocols, which is why it's extendible.

I've asked to add new protocols, because message on uri.allowed-editor-protocols setting change page told me to do this:

Phabricator_EditorProtocol.png (435×1 px, 60 KB)

Haha, well that's news to me!

Probably somebody forgot to update language pack, when decision was made not to support more default editors :)

I think the underlying issue is with parsing URIs that don't have slashes in them. We assume the domain terminates with a slash, but idea://open?... does not. This causes us to incorrectly identify the URI protocol.

Isn't parse_url function (http://php.net/manual/en/function.parse-url.php) used to parse url to determine protocol? I thought it handle that stuff without problems.

We perform filtering after calling parse_url() to deal with cases it doesn't handle. This filtering gets these cases wrong.

Specifically, this is a combination of parse_url() getting these URLs wrong, and then filtering we apply. Here's what parse_url() gets wrong:

$ php -r "var_dump(parse_url('idea://open?a=/'));"
array(3) {
  ["scheme"]=>
  string(4) "idea"
  ["host"]=>
  string(7) "open?a="
  ["path"]=>
  string(1) "/"
}

It incorrectly identifies the host as "open?a=". We then reject this as an invalid host.

Usually host goes till the first ? or if that's missing till the end of the string.

Also the comment textarea in Manifest doesn't clear when I hit Submit button.