mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUAC-589: Fix regression in clipboard support - do not handle Ctrl-V unless clipboard integration is actually enabled.
This commit is contained in:
@@ -28,6 +28,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import org.glyptodon.guacamole.GuacamoleException;
|
||||
import org.glyptodon.guacamole.GuacamoleServerException;
|
||||
import org.glyptodon.guacamole.GuacamoleUnsupportedException;
|
||||
import org.glyptodon.guacamole.net.auth.UserContext;
|
||||
import org.glyptodon.guacamole.properties.BooleanGuacamoleProperty;
|
||||
import org.glyptodon.guacamole.properties.GuacamoleProperties;
|
||||
@@ -79,6 +80,10 @@ public class CaptureClipboard extends AuthenticatingHttpServlet {
|
||||
|
||||
}
|
||||
|
||||
// Otherwise, inform not supported
|
||||
else
|
||||
throw new GuacamoleUnsupportedException("Clipboard integration not supported");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -645,8 +645,8 @@ GuacAdmin.UserEditor = function(name, parameters) {
|
||||
GuacAdmin.reset();
|
||||
|
||||
}
|
||||
catch (e) {
|
||||
alert(e.message);
|
||||
catch (status) {
|
||||
alert(status.message);
|
||||
}
|
||||
|
||||
};
|
||||
@@ -684,8 +684,8 @@ GuacAdmin.UserEditor = function(name, parameters) {
|
||||
}
|
||||
|
||||
// Alert on failure
|
||||
catch (e) {
|
||||
alert(e.message);
|
||||
catch (status) {
|
||||
alert(status.message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -983,8 +983,8 @@ GuacAdmin.ConnectionEditor = function(connection, parameters) {
|
||||
GuacAdmin.reset();
|
||||
|
||||
}
|
||||
catch (e) {
|
||||
alert(e.message);
|
||||
catch (status) {
|
||||
alert(status.message);
|
||||
}
|
||||
|
||||
};
|
||||
@@ -1022,8 +1022,8 @@ GuacAdmin.ConnectionEditor = function(connection, parameters) {
|
||||
}
|
||||
|
||||
// Alert on failure
|
||||
catch (e) {
|
||||
alert(e.message);
|
||||
catch (status) {
|
||||
alert(status.message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1176,8 +1176,8 @@ GuacAdmin.ConnectionGroupEditor = function(group, parameters) {
|
||||
GuacAdmin.reset();
|
||||
|
||||
}
|
||||
catch (e) {
|
||||
alert(e.message);
|
||||
catch (status) {
|
||||
alert(status.message);
|
||||
}
|
||||
|
||||
};
|
||||
@@ -1215,8 +1215,8 @@ GuacAdmin.ConnectionGroupEditor = function(group, parameters) {
|
||||
}
|
||||
|
||||
// Alert on failure
|
||||
catch (e) {
|
||||
alert(e.message);
|
||||
catch (status) {
|
||||
alert(status.message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1406,8 +1406,8 @@ GuacAdmin.reset = function() {
|
||||
}
|
||||
|
||||
// Alert on failure
|
||||
catch (e) {
|
||||
alert(e.message);
|
||||
catch (status) {
|
||||
alert(tatusmessage);
|
||||
}
|
||||
|
||||
};
|
||||
|
@@ -254,7 +254,9 @@ GuacUI.Client = {
|
||||
|
||||
"connectionName" : "Guacamole",
|
||||
"overrideAutoFit" : false,
|
||||
"attachedClient" : null
|
||||
"attachedClient" : null,
|
||||
|
||||
"clipboard_integration_enabled" : undefined,
|
||||
|
||||
};
|
||||
|
||||
@@ -1310,25 +1312,61 @@ GuacUI.Client.attach = function(guac) {
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the contents of the remote clipboard if clipboard integration is
|
||||
* enabled, and null otherwise.
|
||||
*/
|
||||
function get_clipboard_data() {
|
||||
|
||||
// If integration not enabled, do not attempt retrieval
|
||||
if (GuacUI.Client.clipboard_integration_enabled === false)
|
||||
return null;
|
||||
|
||||
// Otherwise, attempt retrieval and update integration status
|
||||
try {
|
||||
var data = GuacamoleService.Clipboard.get();
|
||||
GuacUI.Client.clipboard_integration_enabled = true;
|
||||
return data;
|
||||
}
|
||||
catch (status) {
|
||||
GuacUI.Client.clipboard_integration_enabled = false;
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Set local clipboard contents on cut
|
||||
document.body.addEventListener("cut", function handle_cut(e) {
|
||||
var data = get_clipboard_data();
|
||||
if (data !== null) {
|
||||
e.preventDefault();
|
||||
var data = GuacamoleService.Clipboard.get();
|
||||
e.clipboardData.setData("text/plain", data);
|
||||
}
|
||||
}, false);
|
||||
|
||||
// Set local clipboard contents on copy
|
||||
document.body.addEventListener("copy", function handle_copy(e) {
|
||||
var data = get_clipboard_data();
|
||||
if (data !== null) {
|
||||
e.preventDefault();
|
||||
var data = GuacamoleService.Clipboard.get();
|
||||
e.clipboardData.setData("text/plain", data);
|
||||
}
|
||||
}, false);
|
||||
|
||||
// Set remote clipboard contents on paste
|
||||
document.body.addEventListener("paste", function handle_paste(e) {
|
||||
|
||||
// If status of clipboard integration is unknown, attempt to define it
|
||||
if (GuacUI.Client.clipboard_integration_enabled === undefined)
|
||||
get_clipboard_data();
|
||||
|
||||
// Override and handle paste only if integration is enabled
|
||||
if (GuacUI.Client.clipboard_integration_enabled) {
|
||||
e.preventDefault();
|
||||
if (GuacUI.Client.attachedClient)
|
||||
GuacUI.Client.attachedClient.setClipboard(e.clipboardData.getData("text/plain"));
|
||||
}
|
||||
|
||||
}, false);
|
||||
|
||||
/*
|
||||
|
@@ -325,19 +325,22 @@ GuacamoleService.PermissionSet = function() {
|
||||
GuacamoleService.handleResponse = function(xhr) {
|
||||
|
||||
// For HTTP Forbidden, just return permission denied
|
||||
if (xhr.status == 403)
|
||||
throw new Error("Permission denied.");
|
||||
if (xhr.status === 403)
|
||||
throw new Guacamole.Status(Guacamole.Status.Code.CLIENT_FORBIDDEN, "Permission denied.");
|
||||
|
||||
// Otherwise, if unsuccessful, throw error with message derived from
|
||||
// response
|
||||
if (xhr.status != 200) {
|
||||
if (xhr.status !== 200) {
|
||||
|
||||
// Retrieve error code
|
||||
var code = parseInt(xhr.getResponseHeader("Guacamole-Status-Code"));
|
||||
|
||||
// Retrieve error message
|
||||
var message = xhr.getResponseHeader("Guacamole-Error-Message")
|
||||
|| xhr.statusText;
|
||||
|
||||
// Throw error with derived message
|
||||
throw new Error(message);
|
||||
throw new Guacamole.Status(code, message);
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user