From 413dc86d05cc2d5f84b519dff43b3169db7640c8 Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Wed, 11 May 2022 14:52:25 +0100 Subject: [PATCH] Rename internal "unknown" filter operator so that users cannot invoke it --- core/modules/filters.js | 4 ++-- core/modules/filters/unknown.js | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/core/modules/filters.js b/core/modules/filters.js index 5f4eb6492..808628acb 100644 --- a/core/modules/filters.js +++ b/core/modules/filters.js @@ -247,8 +247,8 @@ exports.compileFilter = function(filterString) { // Use the "title" operator if no operator is specified operatorFunction = filterOperators.title; } else if(!filterOperators[operator.operator]) { - // Unknown operators treated as "unknown" - at run time we can distinguish between a custom operator and falling back to the default "field" operator - operatorFunction = filterOperators.unknown; + // Unknown operators treated as "[unknown]" - at run time we can distinguish between a custom operator and falling back to the default "field" operator + operatorFunction = filterOperators["[unknown]"]; } else { // Use the operator function operatorFunction = filterOperators[operator.operator]; diff --git a/core/modules/filters/unknown.js b/core/modules/filters/unknown.js index c2e2912a4..2eca09a7c 100644 --- a/core/modules/filters/unknown.js +++ b/core/modules/filters/unknown.js @@ -3,7 +3,9 @@ title: $:/core/modules/filters/unknown.js type: application/javascript module-type: filteroperator -Filter operator for handling unknown filter operators +Filter operator for handling unknown filter operators. + +Not intended to be used directly by end users, hence the square brackets around the name. \*/ (function(){ @@ -17,7 +19,7 @@ var fieldFilterOperatorFn = require("$:/core/modules/filters/field.js").field; /* Export our filter function */ -exports.unknown = function(source,operator,options) { +exports["[unknown]"] = function(source,operator,options) { var customDefinitionTitle = "[" + operator.operator + "[]]", customDefinition = options.widget && options.widget.getVariableInfo && options.widget.getVariableInfo(customDefinitionTitle); if(customDefinition && customDefinition.srcVariable && customDefinition.srcVariable.isFunctionDefinition) {