Merge "LOG SQL dump files getting installed"
[sdnc/oam.git] / dgbuilder / dgeflows / node_modules / ejs / lib / utils.js
1 /*
2  * EJS Embedded JavaScript templates
3  * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *         http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17 */
18
19 'use strict';
20
21 var regExpChars = /[|\\{}()[\]^$+*?.]/g;
22
23 exports.escapeRegExpChars = function (string) {
24   // istanbul ignore if
25   if (!string) {
26     return '';
27   }
28   return String(string).replace(regExpChars, '\\$&');
29 };
30
31 var encodeHTMLRules = {
32       '&': '&'
33     , '<': '&lt;'
34     , '>': '&gt;'
35     , '"': '&#34;'
36     , "'": '&#39;'
37     }
38   , matchHTML = /[&<>\'"]/g;
39
40 exports.escapeFuncStr =
41   'var encodeHTMLRules = {'
42 +       '"&": "&amp;"'
43 +     ', "<": "&lt;"'
44 +     ', ">": "&gt;"'
45 +     ', \'"\': "&#34;"'
46 +     ', "\'": "&#39;"'
47 +     '}'
48 +   ', matchHTML = /[&<>\'"]/g;';
49
50 exports.escapeXML = function (markup) {
51   return markup == undefined
52     ? ''
53     : String(markup)
54         .replace(matchHTML, function(m) {
55           return encodeHTMLRules[m] || m;
56         });
57 };
58
59 exports.shallowCopy = function (to, from) {
60   for (var p in from) {
61     to[p] = from[p];
62   }
63   return to;
64 };
65