From 27255ce808593a986ddf30d73d1e3d1970ba4852 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 26 May 2019 20:05:45 +1200 Subject: [PATCH] Whitelist `tsv` extension when opening CSV files Fixes #429 --- CHANGELOG.md | 6 ++++++ src/PhpSpreadsheet/Reader/Csv.php | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bfda7f6..9cf34683 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com) and this project adheres to [Semantic Versioning](https://semver.org). +## [Unreleased] + +### Fixed + +- Whitelist `tsv` extension when opening CSV files [#429](https://github.com/PHPOffice/PhpSpreadsheet/issues/429) + ## [1.7.0] - 2019-05-26 ### Added diff --git a/src/PhpSpreadsheet/Reader/Csv.php b/src/PhpSpreadsheet/Reader/Csv.php index 9e6bccf7..e10da31a 100644 --- a/src/PhpSpreadsheet/Reader/Csv.php +++ b/src/PhpSpreadsheet/Reader/Csv.php @@ -545,7 +545,8 @@ class Csv extends BaseReader fclose($this->fileHandle); // Trust file extension if any - if (strtolower(pathinfo($pFilename, PATHINFO_EXTENSION)) === 'csv') { + $extension = strtolower(pathinfo($pFilename, PATHINFO_EXTENSION)); + if (in_array($extension, ['csv', 'tsv'])) { return true; }