mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
Escape parentheses for dropped files/folders (#1935)
* Escape parentheses for dropped files/folders Fixes #1933 * Cleanup regex * Wrap dropped path in single-quote * Escape single quote inside single quote * Handle escaping with current shell * Cleanup escape
This commit is contained in:
parent
6d99a6df31
commit
0bf10f3768
3 changed files with 21 additions and 8 deletions
20
app/index.js
20
app/index.js
|
|
@ -264,8 +264,18 @@ app.on('ready', () => installDevExtensions(isDev).then(() => {
|
|||
session.resize({cols, rows});
|
||||
});
|
||||
|
||||
rpc.on('data', ({uid, data}) => {
|
||||
sessions.get(uid).write(data);
|
||||
rpc.on('data', ({uid, data, escaped}) => {
|
||||
const session = sessions.get(uid);
|
||||
|
||||
if (escaped) {
|
||||
const escapedData = session.shell.endsWith('cmd.exe') ?
|
||||
`"${data}"` : // This is how cmd.exe does it
|
||||
`'${data.replace(/'/g, `'\\''`)}'`; // Inside a single-quoted string nothing is interpreted
|
||||
|
||||
session.write(escapedData);
|
||||
} else {
|
||||
session.write(data);
|
||||
}
|
||||
});
|
||||
|
||||
rpc.on('open external', ({url}) => {
|
||||
|
|
@ -311,8 +321,10 @@ app.on('ready', () => installDevExtensions(isDev).then(() => {
|
|||
const protocol = typeof url === 'string' && parseUrl(url).protocol;
|
||||
if (protocol === 'file:') {
|
||||
event.preventDefault();
|
||||
const path = fileUriToPath(url).replace(/ /g, '\\ ');
|
||||
rpc.emit('session data send', {data: path});
|
||||
|
||||
const path = fileUriToPath(url);
|
||||
|
||||
rpc.emit('session data send', {data: path, escaped: true});
|
||||
} else if (protocol === 'http:' || protocol === 'https:') {
|
||||
event.preventDefault();
|
||||
rpc.emit('session data send', {data: url});
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ export function resizeSession(uid, cols, rows) {
|
|||
};
|
||||
}
|
||||
|
||||
export function sendSessionData(uid, data) {
|
||||
export function sendSessionData(uid, data, escaped) {
|
||||
return function (dispatch, getState) {
|
||||
dispatch({
|
||||
type: SESSION_USER_DATA,
|
||||
|
|
@ -148,7 +148,8 @@ export function sendSessionData(uid, data) {
|
|||
effect() {
|
||||
// If no uid is passed, data is sent to the active session.
|
||||
const targetUid = uid || getState().sessions.activeUid;
|
||||
rpc.emit('data', {uid: targetUid, data});
|
||||
|
||||
rpc.emit('data', {uid: targetUid, data, escaped});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -70,8 +70,8 @@ rpc.on('session data', d => {
|
|||
}
|
||||
});
|
||||
|
||||
rpc.on('session data send', ({uid, data}) => {
|
||||
store_.dispatch(sessionActions.sendSessionData(uid, data));
|
||||
rpc.on('session data send', ({uid, data, escaped}) => {
|
||||
store_.dispatch(sessionActions.sendSessionData(uid, data, escaped));
|
||||
});
|
||||
|
||||
rpc.on('session exit', ({uid}) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue