Do not depend on PHP_EOL in HTMLRestrictionsField
authorUmherirrender <umherirrender_de.wp@web.de>
Wed, 20 Sep 2017 20:01:34 +0000 (22:01 +0200)
committerUmherirrender <umherirrender_de.wp@web.de>
Wed, 20 Sep 2017 20:01:34 +0000 (22:01 +0200)
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

index dbf2c8f..0310dd0 100644 (file)
@@ -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 );
        }