Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vlucas/phpdotenv
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.6.7
Choose a base ref
...
head repository: vlucas/phpdotenv
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.6.8
Choose a head ref
  • 9 commits
  • 9 files changed
  • 2 contributors

Commits on Nov 21, 2020

  1. Test fixes

    GrahamCampbell committed Nov 21, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    919c01a View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    543f87a View commit details

Commits on Dec 3, 2020

  1. Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    692830c View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    546124f View commit details
  3. Fixed typo

    GrahamCampbell committed Dec 3, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    e778c8b View commit details

Commits on Jan 20, 2021

  1. Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    7417448 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    04e416a View commit details
  3. Revert "Test on PHP 8.1 too (#467)"

    This reverts commit 692830c.
    GrahamCampbell committed Jan 20, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b786088 View commit details
  4. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    5e679f7 View commit details
Showing with 114 additions and 57 deletions.
  1. +0 −1 .gitattributes
  2. +16 −0 .github/bin/composer.sh
  3. +5 −0 .github/bin/hhvm.sh
  4. +33 −3 .github/workflows/tests.yml
  5. +0 −50 .travis.yml
  6. +1 −1 composer.json
  7. +10 −2 src/Parser.php
  8. +13 −0 tests/Dotenv/LinesTest.php
  9. +36 −0 tests/Dotenv/ParserTest.php
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@
/.github export-ignore
/.gitignore export-ignore
/.github export-ignore
/.travis.yml export-ignore
/phpunit.xml.dist export-ignore
/README.md export-ignore
/UPGRADING.md export-ignore
16 changes: 16 additions & 0 deletions .github/bin/composer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

EXPECTED_CHECKSUM="$(wget -q -O - https://composer.github.io/installer.sig)"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]; then
>&2 echo 'ERROR: Invalid installer checksum'
rm composer-setup.php
exit 1
else
php composer-setup.php --install-dir="/usr/bin" --filename=composer
RESULT=$?
rm composer-setup.php
composer config platform.php 5.6.50
exit $RESULT
fi
5 changes: 5 additions & 0 deletions .github/bin/hhvm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

echo "deb https://dl.hhvm.com/ubuntu $(lsb_release -sc)-lts-$1 main" >> /etc/apt/sources.list
apt-get update
apt-get --allow-downgrades --reinstall install hhvm/$(lsb_release -sc)-lts-$1
36 changes: 33 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -5,13 +5,13 @@ on:
pull_request:

jobs:
tests:
php:
name: PHP ${{ matrix.php }}
runs-on: ubuntu-20.04

strategy:
matrix:
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']

steps:
- name: Checkout Code
@@ -40,8 +40,38 @@ jobs:
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --no-interaction --no-progress --ignore-platform-reqs
command: composer update --no-interaction --no-progress --ignore-platform-req=php
if: "matrix.php >= 8"

- name: Execute PHPUnit
run: vendor/bin/phpunit

hhvm:
name: HHVM ${{ matrix.hhvm }}
runs-on: ubuntu-16.04

strategy:
matrix:
hhvm: ["3.15", "3.18", "3.21", "3.24", "3.27", "3.30"]

steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Install HHVM
shell: bash
run: sudo .github/bin/hhvm.sh ${{ matrix.hhvm }}

- name: Install Composer
shell: bash
run: sudo .github/bin/composer.sh

- name: Install Dependencies
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --no-interaction --no-progress

- name: Execute PHPUnit
run: hhvm vendor/bin/phpunit
50 changes: 0 additions & 50 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@
"require-dev": {
"ext-filter": "*",
"ext-pcre": "*",
"phpunit/phpunit": "^4.8.35 || ^5.7.27 || ^6.5.6 || ^7.0"
"phpunit/phpunit": "^4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20"
},
"autoload": {
"psr-4": {
12 changes: 10 additions & 2 deletions src/Parser.php
Original file line number Diff line number Diff line change
@@ -106,7 +106,7 @@ private static function parseValue($value)
return $value;
}

return array_reduce(str_split($value), function ($data, $char) use ($value) {
$result = array_reduce(str_split($value), function ($data, $char) use ($value) {
switch ($data[1]) {
case self::INITIAL_STATE:
if ($char === '"' || $char === '\'') {
@@ -155,7 +155,15 @@ private static function parseValue($value)
case self::COMMENT_STATE:
return [$data[0], self::COMMENT_STATE];
}
}, ['', self::INITIAL_STATE])[0];
}, ['', self::INITIAL_STATE]);

if ($result[1] === self::QUOTED_STATE || $result[1] === self::ESCAPE_STATE) {
throw new InvalidFileException(
self::getErrorMessage('a missing closing quote', $value)
);
}

return $result[0];
}

/**
13 changes: 13 additions & 0 deletions tests/Dotenv/LinesTest.php
Original file line number Diff line number Diff line change
@@ -51,4 +51,17 @@ public function testProcessClosingSlash()

$this->assertSame($expected, $lines);
}

public function testProcessBadQuotes()
{
$lines = [
"TEST=\"erert\nTEST='erert\n",
];

$expected = [
"TEST=\"erert\nTEST='erert\n",
];

$this->assertSame($expected, $lines);
}
}
36 changes: 36 additions & 0 deletions tests/Dotenv/ParserTest.php
Original file line number Diff line number Diff line change
@@ -106,4 +106,40 @@ public function testParserEscapingSingle()
{
Parser::parse('FOO_BAD=\'iiiiviiiixiiiiviiii\\a\'');
}

/**
* @expectedException \Dotenv\Exception\InvalidFileException
* @expectedExceptionMessage Failed to parse dotenv file due to a missing closing quote. Failed at ['erert].
*/
public function testMissingClosingSingleQuote()
{
Parser::parse('TEST=\'erert');
}

/**
* @expectedException \Dotenv\Exception\InvalidFileException
* @expectedExceptionMessage Failed to parse dotenv file due to a missing closing quote. Failed at ["erert].
*/
public function testMissingClosingDoubleQuote()
{
Parser::parse('TEST="erert');
}

/**
* @expectedException \Dotenv\Exception\InvalidFileException
* @expectedExceptionMessage Failed to parse dotenv file due to a missing closing quote. Failed at ["erert].
*/
public function testMissingClosingQuotes()
{
Parser::parse("TEST=\"erert\nTEST='erert\n");
}

/**
* @expectedException \Dotenv\Exception\InvalidFileException
* @expectedExceptionMessage Failed to parse dotenv file due to a missing closing quote. Failed at ["\].
*/
public function testMissingClosingQuoteWithEscape()
{
Parser::parse('TEST="\\');
}
}