archimatetool / archi-scripting-plugin

jArchi - Scripting for Archi: ArchiMate Modelling Tool
https://www.archimatetool.com
118 stars 33 forks source link

jArchi script fails to run when path has an apostrophe in it #109

Closed InceptusSolutions closed 1 year ago

InceptusSolutions commented 1 year ago

Version of Archi

Archi 4:0.0

Archi Plug-ins

coArchi 0.8.3 Excel 0.2.1 jArchi 1.2.1 Lightbox 1.1.1

(Note: The bug may be a jArchi bug or even a JavaScript Bug)

Operating System

Windows 11 (&10)

Expected Behaviour

I have set the path for my scripts directory to a synched local path of a SharePoint site. C:\Users...\Barnardo's...\Modelling Tools\Archi\Archi scripts

I expect the script I have selected to run.

Actual Behaviour

When I try to run any script I get an error message in the console as follows. Script Error: javax.script.ScriptException: org.graalvm.polyglot.PolyglotException: SyntaxError: :1:30 Expected , but found s load('C:/Users/.../Barnardo's/.../Modelling Tools/Archi/Archi scripts/Barnardos/resizeCanvas.ajs') ^

:1:172 Missing close quote load('C:/Users/.../Barnardo's/.../Modelling Tools/Archi/Archi scripts/Barnardos/resizeCanvas.ajs') The same set of scripts work perfectly if run from a different location - even if they are synched from a different SharePoint site. The problem is the script never loads, this could be a JavaScript Bug I suppose but the load('...') statement fails to actually load the script due to the path legitimately having and apostrophe in it. ### Steps to Reproduce the Behaviour 1. Create a path with and apostrophe in it 2. move your scripts to this location 3. in preferences change the scripts directory to the folder under the path with the apostrophe 4. try to run one of the scripts
Phillipus commented 1 year ago

Hi, thanks for the report which I can reproduce.

The problem is caused by jArchi evaluating the script file using the load('filepath') JS function with an extra apostrophe in the file path.

I'll escape any apostrophes in the file path with \\\' for the next version of jArchi. Until then, you'll have to use a path without apostrophes.

InceptusSolutions commented 1 year ago

Hi, thanks for the report which I can reproduce.

The problem is caused by jArchi evaluating the script file using the load('filepath') JS function with an extra apostrophe in the file path.

I'll escape any apostrophes in the file path with \\\' for the next version of jArchi. Until then, you'll have to use a path without apostrophes.

Thanks Phil

Phillipus commented 1 year ago

This is now fixed in jArchi 1.3