screenshot: Also validate parameters to FlashArea()
Apply the same parameter validation to FlashArea() we already use for ScreenshotArea(). https://bugzilla.gnome.org/show_bug.cgi?id=731220
This commit is contained in:
parent
4fe0353991
commit
5852c17f76
@ -67,6 +67,13 @@ const ScreenshotService = new Lang.Class({
|
|||||||
Gio.DBus.session.own_name('org.gnome.Shell.Screenshot', Gio.BusNameOwnerFlags.REPLACE, null, null);
|
Gio.DBus.session.own_name('org.gnome.Shell.Screenshot', Gio.BusNameOwnerFlags.REPLACE, null, null);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_checkArea: function(x, y, width, height) {
|
||||||
|
return x >= 0 && y >= 0 &&
|
||||||
|
width > 0 && height > 0 &&
|
||||||
|
x + width <= global.screen_width &&
|
||||||
|
y + height <= global.screen_height;
|
||||||
|
},
|
||||||
|
|
||||||
_onScreenshotComplete: function(obj, result, area, filenameUsed, flash, invocation) {
|
_onScreenshotComplete: function(obj, result, area, filenameUsed, flash, invocation) {
|
||||||
if (flash && result) {
|
if (flash && result) {
|
||||||
let flashspot = new Flashspot(area);
|
let flashspot = new Flashspot(area);
|
||||||
@ -79,10 +86,9 @@ const ScreenshotService = new Lang.Class({
|
|||||||
|
|
||||||
ScreenshotAreaAsync : function (params, invocation) {
|
ScreenshotAreaAsync : function (params, invocation) {
|
||||||
let [x, y, width, height, flash, filename, callback] = params;
|
let [x, y, width, height, flash, filename, callback] = params;
|
||||||
if (x < 0 || y < 0 ||
|
if (!this._checkArea(x, y, width, height)) {
|
||||||
width <= 0 || height <= 0 ||
|
invocation.return_error_literal(Gio.IOErrorEnum,
|
||||||
x + width > global.screen_width || y + height > global.screen_height) {
|
Gio.IOErrorEnum.CANCELLED,
|
||||||
invocation.return_error_literal(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED,
|
|
||||||
"Invalid params");
|
"Invalid params");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -125,9 +131,17 @@ const ScreenshotService = new Lang.Class({
|
|||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
FlashArea: function(x, y, width, height) {
|
FlashAreaAsync: function(params, invocation) {
|
||||||
|
let [x, y, width, height] = params;
|
||||||
|
if (!this._checkArea(x, y, width, height)) {
|
||||||
|
invocation.return_error_literal(Gio.IOErrorEnum,
|
||||||
|
Gio.IOErrorEnum.CANCELLED,
|
||||||
|
"Invalid params");
|
||||||
|
return;
|
||||||
|
}
|
||||||
let flashspot = new Flashspot({ x : x, y : y, width: width, height: height});
|
let flashspot = new Flashspot({ x : x, y : y, width: width, height: height});
|
||||||
flashspot.fire();
|
flashspot.fire();
|
||||||
|
invocation.return_value(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user