Skip to content

Commit

Permalink
fix for #906, 1) windows paths like C:\a\b weren't accepted because b… (
Browse files Browse the repository at this point in the history
#935)

* fix for #906, 1) windows paths like C:\a\b weren't accepted because backslashes were treated as escape sequences, 2) common paths like C:\Program Files\Foo\Foo.exe weren't accepted because of the space in the path

* Using anothing approach,
a) backslashes are no longer treated as escape characters,
b) string change to remind people to add spaces

* Removing joplin.pot from the patch, it will be updated later.

* Removing unused code.
  • Loading branch information
moltenform authored and laurent22 committed Nov 20, 2018
1 parent 0a0afd7 commit 58b68ca
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 4 additions & 1 deletion ReactNativeClient/lib/models/Setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ class Setting extends BaseModel {
}},
'noteVisiblePanes': { value: ['editor', 'viewer'], type: Setting.TYPE_ARRAY, public: false, appTypes: ['desktop'] },
'sidebarVisibility': { value: true, type: Setting.TYPE_BOOL, public: false, appTypes: ['desktop'] },
'editor': { value: '', type: Setting.TYPE_STRING, public: true, appTypes: ['cli', 'desktop'], label: () => _('Text editor command'), description: () => _('The editor command (may include arguments) that will be used to open a note. If none is provided it will try to auto-detect the default editor.') },
'editor': { value: '', type: Setting.TYPE_STRING, public: true, appTypes: ['cli', 'desktop'], label: () => _('Text editor command'), description: () =>
shim.isWindows() ?
_('The editor that will be used to open a note. Use quotes like \"C:\\Program Files\\Edit.exe\" if the path contains spaces. May include arguments. If none is provided it will try to auto-detect the default editor.') :
_('The editor command (may include arguments) that will be used to open a note. If none is provided it will try to auto-detect the default editor.') },
'showAdvancedOptions': { value: false, type: Setting.TYPE_BOOL, public: true, appTypes: ['mobile' ], label: () => _('Show advanced options') },
'sync.target': { value: SyncTargetRegistry.nameToId('dropbox'), type: Setting.TYPE_INT, isEnum: true, public: true, label: () => _('Synchronisation target'), description: (appType) => { return appType !== 'cli' ? null : _('The target to synchonise to. Each sync target may have additional parameters which are named as `sync.NUM.NAME` (all documented below).') }, options: () => {
return SyncTargetRegistry.idAndLabelPlainObject();
Expand Down
3 changes: 1 addition & 2 deletions ReactNativeClient/lib/services/ExternalEditWatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ class ExternalEditWatcher {
const editorCommand = Setting.value('editor');
if (!editorCommand) return null;

const s = splitCommandString(editorCommand);

const s = splitCommandString(editorCommand, {handleEscape: false});
const path = s.splice(0, 1);
if (!path.length) throw new Error('Invalid editor command: ' + editorCommand);

Expand Down
9 changes: 7 additions & 2 deletions ReactNativeClient/lib/string-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,12 @@ function wrap(text, indent, width) {
});
}

function splitCommandString(command) {
function splitCommandString(command, options = null) {
options = options || {};
if (!('handleEscape' in options)) {
options.handleEscape = true;
}

let args = [];
let state = "start"
let current = ""
Expand All @@ -148,7 +153,7 @@ function splitCommandString(command) {
continue;
}

if (c == "\\") {
if (c == "\\" && options.handleEscape) {
escapeNext = true;
continue;
}
Expand Down

0 comments on commit 58b68ca

Please sign in to comment.