[gjs: 3/5] GObject: Sanitize provided GTypeName to match allowed ones
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 3/5] GObject: Sanitize provided GTypeName to match allowed ones
- Date: Thu, 24 Oct 2019 05:22:45 +0000 (UTC)
commit 75851760363bd59c8dce3de957129645625f83f2
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Sun Sep 1 09:05:19 2019 +0200
GObject: Sanitize provided GTypeName to match allowed ones
When the GTypeName property is passed to GObject.registerClass
we don't check for string validity, so fix this, but log an error
informing what happened.
modules/overrides/GObject.js | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/modules/overrides/GObject.js b/modules/overrides/GObject.js
index cccbf228..a18421ae 100644
--- a/modules/overrides/GObject.js
+++ b/modules/overrides/GObject.js
@@ -151,8 +151,14 @@ function _getCallerBasename() {
function _createGTypeName(klass) {
const sanitizeGType = s => s.replace(/[^a-z0-9+_-]/gi, '_');
- if (klass.hasOwnProperty(GTypeName))
- return klass[GTypeName];
+ if (klass.hasOwnProperty(GTypeName)) {
+ let sanitized = sanitizeGType(klass[GTypeName]);
+ if (sanitized !== klass[GTypeName]) {
+ logError(new RangeError(`Provided GType name '${klass[GTypeName]}' ` +
+ `is not valid; automatically sanitized to '${sanitized}'`));
+ }
+ return sanitized;
+ }
let gtypeClassName = klass.name;
if (GObject.gtypeNameBasedOnJSPath) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]