Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

fix array for-in to only process own properties of array #10

Open
wants to merge 1 commit into from

1 participant

@mshick
Collaborator

I was having a nightmare of a time with this. An array prototype property, stackSize, was getting processed as data.

This check ensures only real array values will get processed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 11 deletions.
  1. +13 −11 lib/document.js
View
24 lib/document.js
@@ -154,17 +154,19 @@ var solrDoc = function() {
for ( var o in fields) {
if (Array.isArray(fields[o])) {
for ( var oo in fields[o]) {
- data += '<field name="'
- + o
- + '"'
- + (this.getFieldUpdate(o) ? ' update="' // new
- + this.getFieldUpdate(o) + '"' : '') // new
- + (this.getFieldDelete(o) ? ' null="' // new
- + this.getFieldDelete(o) + '"' : '') // new
- + (this.getFieldBoost(o) ? ' boost="'
- + parseFloat(this.getFieldBoost(o)) + '"' : '') + '>';
- data += utils.escapeXML(fields[o][oo]);
- data += '</field>';
+ if (fields[o].hasOwnProperty(oo)) {
+ data += '<field name="'
+ + o
+ + '"'
+ + (this.getFieldUpdate(o) ? ' update="' // new
+ + this.getFieldUpdate(o) + '"' : '') // new
+ + (this.getFieldDelete(o) ? ' null="' // new
+ + this.getFieldDelete(o) + '"' : '') // new
+ + (this.getFieldBoost(o) ? ' boost="'
+ + parseFloat(this.getFieldBoost(o)) + '"' : '') + '>';
+ data += utils.escapeXML(fields[o][oo]);
+ data += '</field>';
+ }
}
} else {
data += '<field name="'
Something went wrong with that request. Please try again.