Skip to content
This repository was archived by the owner on Jan 7, 2021. It is now read-only.

Commit 1af71b6

Browse files
committed
Adds editorconfig and fixes code formatting
1 parent 015c5e2 commit 1af71b6

3 files changed

Lines changed: 59 additions & 45 deletions

File tree

.editorconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
root = true
2+
3+
; Unix-style newlines with a newline ending every file
4+
[*]
5+
end_of_line = lf
6+
insert_final_newline = true
7+
charset = utf-8
8+
9+
; JS
10+
[*.js]
11+
indent_style = space
12+
indent_size = 4
13+
trim_trailing_whitespace = true
14+
insert_final_newline = true

lib/json2xml.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ ToXml.prototype.openTag = function(key) {
7575
this.tagIncomplete = true;
7676
}
7777
ToXml.prototype.addAttr = function(key, val) {
78-
if (this.options.sanitize) {
79-
val = sanitizer.sanitize(val)
80-
}
78+
if (this.options.sanitize) {
79+
val = sanitizer.sanitize(val)
80+
}
8181
this.xml += ' ' + key + '="' + val + '"';
8282
}
8383
ToXml.prototype.addTextContent = function(text) {
@@ -99,13 +99,13 @@ function ToXml(options) {
9999
sanitize: false
100100
};
101101

102-
if (options) {
103-
for (var opt in options) {
104-
defaultOpts[opt] = options[opt];
105-
}
106-
}
102+
if (options) {
103+
for (var opt in options) {
104+
defaultOpts[opt] = options[opt];
105+
}
106+
}
107107

108-
this.options = defaultOpts;
108+
this.options = defaultOpts;
109109
this.xml = '';
110110
this.tagIncomplete = false;
111111
}

lib/sanitize.js

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
/**
2-
* Simple sanitization. It is not intended to sanitize
3-
* malicious element values.
4-
*
5-
* character | escaped
6-
* < &lt;
7-
* > &gt;
8-
* ( &#40;
9-
* ) &#41;
10-
* # &#35;
11-
* & &amp;
12-
* " &quot;
13-
* ' &apos;
14-
*/
15-
var chars = {
16-
'<': '&lt;',
17-
'>': '&gt;',
18-
'(': '&#40;',
19-
')': '&#41;',
20-
'#': '&#35;',
21-
'&': '&amp;',
22-
'"': '&quot;',
23-
"'": '&apos;'
24-
};
25-
26-
exports.sanitize = function sanitize(value) {
27-
if (typeof value !== 'string') {
28-
return value;
29-
}
30-
31-
Object.keys(chars).forEach(function(key) {
32-
value = value.replace(key, chars[key]);
33-
});
34-
35-
return value;
36-
}
1+
/**
2+
* Simple sanitization. It is not intended to sanitize
3+
* malicious element values.
4+
*
5+
* character | escaped
6+
* < &lt;
7+
* > &gt;
8+
* ( &#40;
9+
* ) &#41;
10+
* # &#35;
11+
* & &amp;
12+
* " &quot;
13+
* ' &apos;
14+
*/
15+
var chars = {
16+
'<': '&lt;',
17+
'>': '&gt;',
18+
'(': '&#40;',
19+
')': '&#41;',
20+
'#': '&#35;',
21+
'&': '&amp;',
22+
'"': '&quot;',
23+
"'": '&apos;'
24+
};
25+
26+
exports.sanitize = function sanitize(value) {
27+
if (typeof value !== 'string') {
28+
return value;
29+
}
30+
31+
Object.keys(chars).forEach(function(key) {
32+
value = value.replace(key, chars[key]);
33+
});
34+
35+
return value;
36+
}

0 commit comments

Comments
 (0)