pg 6.1.5 → 6.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/result.js +8 -7
  2. package/package.json +2 -1
package/lib/result.js CHANGED
@@ -7,6 +7,7 @@
7
7
  */
8
8
 
9
9
  var types = require('pg-types');
10
+ var escape = require('js-string-escape');
10
11
 
11
12
  //result object returned from query
12
13
  //in the 'end' event and also
@@ -75,13 +76,13 @@ Result.prototype.addRow = function(row) {
75
76
 
76
77
  var inlineParser = function(fieldName, i) {
77
78
  return "\nthis['" +
78
- //fields containing single quotes will break
79
- //the evaluated javascript unless they are escaped
80
- //see https://github.com/brianc/node-postgres/issues/507
81
- //Addendum: However, we need to make sure to replace all
82
- //occurences of apostrophes, not just the first one.
83
- //See https://github.com/brianc/node-postgres/issues/934
84
- fieldName.replace(/'/g, "\\'") +
79
+ // fields containing single quotes will break
80
+ // the evaluated javascript unless they are escaped
81
+ // see https://github.com/brianc/node-postgres/issues/507
82
+ // Addendum: However, we need to make sure to replace all
83
+ // occurences of apostrophes, not just the first one.
84
+ // See https://github.com/brianc/node-postgres/issues/934
85
+ escape(fieldName) +
85
86
  "'] = " +
86
87
  "rowData[" + i + "] == null ? null : parsers[" + i + "](rowData[" + i + "]);";
87
88
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pg",
3
- "version": "6.1.5",
3
+ "version": "6.1.6",
4
4
  "description": "PostgreSQL client - pure javascript & libpq with the same API",
5
5
  "keywords": [
6
6
  "postgres",
@@ -19,6 +19,7 @@
19
19
  "main": "./lib",
20
20
  "dependencies": {
21
21
  "buffer-writer": "1.0.1",
22
+ "js-string-escape": "1.0.1",
22
23
  "packet-reader": "0.2.0",
23
24
  "pg-connection-string": "0.1.3",
24
25
  "pg-pool": "1.*",