This is an automated email from the ASF dual-hosted git repository. andy pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/jena.git
The following commit(s) were added to refs/heads/main by this push: new afc51dec52 GH-2446: Lookup by proper name for javascript afc51dec52 is described below commit afc51dec52508dff3a2da84a781c69d6af93810e Author: Andy Seaborne <a...@apache.org> AuthorDate: Thu May 2 13:35:42 2024 +0100 GH-2446: Lookup by proper name for javascript --- .../sparql/function/scripting/ScriptFunction.java | 4 +- .../scripting/TestSPARQLCustomFunctions.java | 46 ---------------------- jena-arq/testing/ARQ/Scripting/manifest.ttl | 2 +- 3 files changed, 4 insertions(+), 48 deletions(-) diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/function/scripting/ScriptFunction.java b/jena-arq/src/main/java/org/apache/jena/sparql/function/scripting/ScriptFunction.java index 062c35bd30..8fafddbec5 100644 --- a/jena-arq/src/main/java/org/apache/jena/sparql/function/scripting/ScriptFunction.java +++ b/jena-arq/src/main/java/org/apache/jena/sparql/function/scripting/ScriptFunction.java @@ -126,6 +126,7 @@ public class ScriptFunction extends FunctionBase { // this.denyList = Set.of("eval", "exec"); // check(lang, name, allowList, denyList); // break; + // No other names allowed, not even synonyms. default: throw new ScriptDenyException("Language '"+lang+"' not recognized"); } @@ -197,7 +198,8 @@ public class ScriptFunction extends FunctionBase { } private Invocable createEngine() { - ScriptEngine engine = scriptEngineManager.getEngineByName(lang); + String lookupLang = "js".equals(lang) ? "javascript" : lang; + ScriptEngine engine = scriptEngineManager.getEngineByName(lookupLang); if (engine == null) throw new ExprException("Unknown scripting language: " + lang); // Enforce Nashorn compatibility for Graal.js diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/function/scripting/TestSPARQLCustomFunctions.java b/jena-arq/src/test/java/org/apache/jena/sparql/function/scripting/TestSPARQLCustomFunctions.java deleted file mode 100644 index 1ec0314388..0000000000 --- a/jena-arq/src/test/java/org/apache/jena/sparql/function/scripting/TestSPARQLCustomFunctions.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.sparql.function.scripting; - -import static org.apache.jena.sparql.function.scripting.TestScriptFunction.DIR; - -import org.apache.jena.query.ARQ; -import org.apache.jena.query.Query; -import org.apache.jena.query.QueryFactory; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -public class TestSPARQLCustomFunctions { - - @BeforeClass public static void enableScripting() { - System.setProperty(ARQ.systemPropertyScripting, "true"); - } - - @AfterClass public static void disableScripting() { - System.clearProperty(ARQ.systemPropertyScripting); - } - - @Test public void script_sparql_bad_1() { - Query query = QueryFactory.read(DIR+"/js-query-5.rq"); - } - - - -} diff --git a/jena-arq/testing/ARQ/Scripting/manifest.ttl b/jena-arq/testing/ARQ/Scripting/manifest.ttl index 359d0f1132..aea79e4e84 100644 --- a/jena-arq/testing/ARQ/Scripting/manifest.ttl +++ b/jena-arq/testing/ARQ/Scripting/manifest.ttl @@ -47,5 +47,5 @@ qt:data <data.ttl> ] ; mf:result <js-query-4.srj> ] - ## js-query-5 is a build time error. + ## js-query-5 is an error and run separately. ).