From ffaf38ce982203961d39d6f3ac640acdf45a038d Mon Sep 17 00:00:00 2001 From: Umherirrender Date: Wed, 20 Sep 2017 22:01:34 +0200 Subject: [PATCH] Do not depend on PHP_EOL in HTMLRestrictionsField HTMLRestrictionsFieldTest::provideValidate only provide test cases with \n, which fails on windows machine. I see no reason to use the system depending constant here Change-Id: I7caf2c4d06c84cac69e20e03d00a93bcd8e7d405 --- includes/htmlform/fields/HTMLRestrictionsField.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/htmlform/fields/HTMLRestrictionsField.php b/includes/htmlform/fields/HTMLRestrictionsField.php index dbf2c8f644..0310dd024f 100644 --- a/includes/htmlform/fields/HTMLRestrictionsField.php +++ b/includes/htmlform/fields/HTMLRestrictionsField.php @@ -38,7 +38,7 @@ class HTMLRestrictionsField extends HTMLTextAreaField { } $value = rtrim( $request->getText( $this->mName ), "\r\n" ); - $ips = $value === '' ? [] : explode( PHP_EOL, $value ); + $ips = $value === '' ? [] : explode( "\n", $value ); try { return MWRestrictions::newFromArray( [ 'IPAddresses' => $ips ] ); } catch ( InvalidArgumentException $e ) { @@ -79,7 +79,7 @@ class HTMLRestrictionsField extends HTMLTextAreaField { if ( is_string( $value ) ) { // MWRestrictions::newFromArray failed; one of the IP ranges must be invalid $status = Status::newGood(); - foreach ( explode( PHP_EOL, $value ) as $range ) { + foreach ( explode( "\n", $value ) as $range ) { if ( !\IP::isIPAddress( $range ) ) { $status->fatal( 'restrictionsfield-badip', $range ); } @@ -103,7 +103,7 @@ class HTMLRestrictionsField extends HTMLTextAreaField { */ public function getInputHTML( $value ) { if ( $value instanceof MWRestrictions ) { - $value = implode( PHP_EOL, $value->toArray()['IPAddresses'] ); + $value = implode( "\n", $value->toArray()['IPAddresses'] ); } return parent::getInputHTML( $value ); } @@ -114,7 +114,7 @@ class HTMLRestrictionsField extends HTMLTextAreaField { */ public function getInputOOUI( $value ) { if ( $value instanceof MWRestrictions ) { - $value = implode( PHP_EOL, $value->toArray()['IPAddresses'] ); + $value = implode( "\n", $value->toArray()['IPAddresses'] ); } return parent::getInputOOUI( $value ); } -- 2.20.1