@@ -11,6 +11,9 @@ defaults = require('./defaults').defaults
11
11
isEmpty = (thing ) ->
12
12
return typeof thing is " object" && thing? && Object .keys (thing).length is 0
13
13
14
+ isValidKey = (key ) ->
15
+ return key != ' __proto__' && key != ' constructor' && key != ' prototype'
16
+
14
17
processItem = (processors , item , key ) ->
15
18
item = process (item, key) for process in processors
16
19
return item
@@ -52,8 +55,7 @@ class exports.Parser extends events
52
55
@ emit err
53
56
54
57
assignOrPush : (obj , key , newValue ) =>
55
- return if key == ' __proto__'
56
- return if key == ' constructor'
58
+ return if not isValidKey (key)
57
59
if key not of obj
58
60
if not @options .explicitArray
59
61
obj[key] = newValue
@@ -112,9 +114,10 @@ class exports.Parser extends events
112
114
obj[attrkey] = {}
113
115
newValue = if @options .attrValueProcessors then processItem (@options .attrValueProcessors , node .attributes [key], key) else node .attributes [key]
114
116
processedKey = if @options .attrNameProcessors then processItem (@options .attrNameProcessors , key) else key
115
- if @options .mergeAttrs
116
- @ assignOrPush obj, processedKey, newValue
117
- else
117
+ if isValidKey (processedKey)
118
+ if @options .mergeAttrs
119
+ @ assignOrPush obj, processedKey, newValue
120
+ else
118
121
@ assignOrPush obj[attrkey], processedKey, newValue
119
122
120
123
# need a place to store the node name
0 commit comments