Skip to content

Commit c4306a8

Browse files
Merge pull request #51 from patrickrobrecht/fix-csv-injection
Fix CSV injection, release 2.6.4
2 parents 815b1c5 + b1a5b78 commit c4306a8

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
11+
## Version 2.6.4
12+
1013
### Changed
1114
- Updated dependencies, including the Chartist library used for the charts
1215

16+
### Security
17+
- Precede cell values starting with = or another spreadsheet meta-character with a single quote to avoid CSV injection
18+
1319

1420
## Version 2.x
1521

extended-evaluation-for-statify.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: Statify – Extended Evaluation
44
* Plugin URI: https://patrick-robrecht.de/wordpress/
55
* Description: Extended evaluation for the compact, easy-to-use and privacy-compliant Statify plugin.
6-
* Version: 2.6.3
6+
* Version: 2.6.4
77
* Author: Patrick Robrecht
88
* Author URI: https://patrick-robrecht.de/
99
* License: GPLv3
@@ -16,7 +16,7 @@
1616
// Exit if accessed directly.
1717
defined( 'ABSPATH' ) || exit;
1818

19-
define( 'EEFSTATFIFY_VERSION', '2.6.3' );
19+
define( 'EEFSTATFIFY_VERSION', '2.6.4' );
2020

2121
// Includes.
2222
require_once 'inc/queries.php';

js/functions.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ function eefstatifyTableToCsv(table, filename) {
55
// Actual delimiters for CSV.
66
colDelim = '","',
77
rowDelim = '"\r\n"',
8+
forbiddenStartCharacters = ['+', '-', '=', '@'],
89
rows = table.find('tr'),
910
csv =
1011
'"' +
@@ -13,7 +14,19 @@ function eefstatifyTableToCsv(table, filename) {
1314
return jQuery(row)
1415
.find('td,th')
1516
.map(function (j, col) {
16-
return jQuery(col).text().replace(/"/g, '""'); // escape double quotes
17+
let text = jQuery(col).text();
18+
// Escape double quotes and trim result.
19+
text = text.replace(/"/g, '""').trim();
20+
// Precede cell values starting with = or another spreadsheet meta-character with a single quote to avoid CSV injection.
21+
const startCharacter = text.substring(0, 1);
22+
if (
23+
forbiddenStartCharacters.includes(
24+
startCharacter
25+
)
26+
) {
27+
text = "'" + text;
28+
}
29+
return text;
1730
})
1831
.get()
1932
.join(tmpColDelim);

readme.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Tags: stats, analytics, privacy, statistics
44
Requires at least: 4.4
55
Tested up to: 6.3
66
Requires PHP: 5.4
7-
Stable tag: 2.6.3
7+
Stable tag: 2.6.4
88
License: GPLv3
99
License URI: https://www.gnu.org/licenses/gpl-3.0.html
1010

@@ -60,6 +60,10 @@ Therefore you'll have to add the *see_statify_evaluation* capability to the user
6060

6161
Please see [the changelog at GitHub](https://github.com/patrickrobrecht/extended-evaluation-for-statify/blob/master/CHANGELOG.md) for the details.
6262

63+
= 2.6.4 =
64+
- Bugfix: Updated dependencies, including the Chartist library used for the charts
65+
- Security fix: Precede cell values starting with = or another spreadsheet meta-character with a single quote to avoid CSV injection
66+
6367
= 2.6.3 =
6468
* Bugfix: Index and post title tooltip in most popular posts diagram (introduced with bugfix version 2.6.2)
6569
* Bugfix: Add selected date range to the subtitle in most popular posts diagram
@@ -84,5 +88,5 @@ Please see [the changelog at GitHub](https://github.com/patrickrobrecht/extended
8488

8589
== Upgrade Notice ==
8690

87-
= 2.6.3 =
88-
This release fixes bugs in the most popular posts diagram.
91+
= 2.6.4 =
92+
This release contains a security fix and all users are encouraged to update to this version.

0 commit comments

Comments
 (0)