Skip to content
Snippets Groups Projects
Commit df575195 authored by Johannes Goderbauer's avatar Johannes Goderbauer
Browse files

Importer: fix errors if a value that contains a CR or LF is evaluated

parent eca2d03b
No related branches found
No related tags found
No related merge requests found
......@@ -10,15 +10,30 @@ import("system.text");
import("ImporterCustomMappingFunctions_lib");
import("ImporterMappingFunctions_lib");
/////////////////////////////////////////////////////////////////////
/// importer module constructor function ///
/// DO NOT TOUCH - use lib_importerCustomMappingFunctions ///
///////////////////////////////////////////////////////////////////
/*
┌─────────────────────────────────────────────────────────────┐
│ importer module constructor function │
│ DO NOT TOUCH - use lib_importerCustomMappingFunctions │
└─────────────────────────────────────────────────────────────┘
Frequently asked questions:
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Q: Why does the importer have a own versionsystem, if there exists git?
A: Because its a standalone module and there is no modularisation-system right now.
So you may want to update the IMPORTER-module and have to keep an eye on the verison.
Q: Where can I see the version of the importer?
A: There is a @version-tag in the documentation of the Importer-function (constructor-function for the object)
*/
/*
* the importer class, main object
* @param {String []} pConfig req ( Name, FunktionsArt, Details )
*
* @version 2.0
* @version 2.1
*
*
* @return {void}
*/
......@@ -1280,8 +1295,13 @@ function Importer(pConfig)
//transform ' to \\u0027 which is in eval a \u0027; transform " to \\u0022 which is in eval a \u0022
//needed for eval like: "'3'2' != ''"
//also escape LF and CR to prevent unterminated string errors
//if the transform of LF and CR cause problems:
//- remove the 2 replaces
//- document in the comment why it should not be used and when it will cause other problems
//- find another solution to prevent the unterminated string errors
if(pEvalScript)
return res.replace("'", "\\\\u0027", "g").replace("\"", "\\\\u0022", "g");
return res.replace("'", "\\\\u0027", "g").replace("\"", "\\\\u0022", "g").replace("\r", "\\\\u000D", "g").replace("\n", "\\\\u000A", "g");
else
return res;
}
......@@ -1289,8 +1309,13 @@ function Importer(pConfig)
{
//transform ' to \\u0027 which is in eval a \u0027; transform " to \\u0022 which is in eval a \u0022
//needed for eval like: "'3'2' != ''"
//also escape LF and CR to prevent unterminated string errors
//if the transform of LF and CR cause problems:
//- remove the 2 replaces
//- document in the comment why it should not be used and when it will cause other problems
//- find another solution to prevent the unterminated string errors
if(pEvalScript)
return inp[Number(pNumber)].replace("'", "\\\\u0027", "g").replace("\"", "\\\\u0022", "g");
return inp[Number(pNumber)].replace("'", "\\\\u0027", "g").replace("\"", "\\\\u0022", "g").replace("\r", "\\\\u000D", "g").replace("\n", "\\\\u000A", "g");
else
return inp[Number(pNumber)];
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment