Skip to content

Commit b9ff6ff

Browse files
author
Mark Scherer
committed
Push security fix for IP address.
1 parent e0ce6e6 commit b9ff6ff

File tree

3 files changed

+15
-19
lines changed

3 files changed

+15
-19
lines changed

Lib/Utility/Utility.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -145,20 +145,10 @@ public static function strSplit($str, $length = 1) {
145145
public static function getClientIp($safe = true) {
146146
if (!$safe && env('HTTP_X_FORWARDED_FOR')) {
147147
$ipaddr = preg_replace('/(?:,.*)/', '', env('HTTP_X_FORWARDED_FOR'));
148+
} elseif (!$safe && env('HTTP_CLIENT_IP')) {
149+
$ipaddr = env('HTTP_CLIENT_IP');
148150
} else {
149-
if (env('HTTP_CLIENT_IP')) {
150-
$ipaddr = env('HTTP_CLIENT_IP');
151-
} else {
152-
$ipaddr = env('REMOTE_ADDR');
153-
}
154-
}
155-
156-
if (env('HTTP_CLIENTADDRESS')) {
157-
$tmpipaddr = env('HTTP_CLIENTADDRESS');
158-
159-
if (!empty($tmpipaddr)) {
160-
$ipaddr = preg_replace('/(?:,.*)/', '', $tmpipaddr);
161-
}
151+
$ipaddr = env('REMOTE_ADDR');
162152
}
163153
return trim($ipaddr);
164154
}

Test/Case/View/Helper/FormatHelperTest.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,19 +136,23 @@ public function testSpeedOfIcons() {
136136
*/
137137
public function testFontIcon() {
138138
$result = $this->Format->fontIcon('signin');
139-
$expected = '<i class="fa-signin"></i>';
139+
$expected = '<i class="fa fa-signin"></i>';
140140
$this->assertEquals($expected, $result);
141141

142142
$result = $this->Format->fontIcon('signin', ['rotate' => 90]);
143-
$expected = '<i class="fa-signin fa-rotate-90"></i>';
143+
$expected = '<i class="fa fa-signin fa-rotate-90"></i>';
144144
$this->assertEquals($expected, $result);
145145

146146
$result = $this->Format->fontIcon('signin', ['size' => 5, 'extra' => ['muted']]);
147-
$expected = '<i class="fa-signin fa-muted fa-5x"></i>';
147+
$expected = '<i class="fa fa-signin fa-muted fa-5x"></i>';
148+
$this->assertEquals($expected, $result);
149+
150+
$result = $this->Format->fontIcon('asterisk', ['namespace' => 'glyphicon']);
151+
$expected = '<i class="glyphicon glyphicon-asterisk"></i>';
148152
$this->assertEquals($expected, $result);
149153

150154
$result = $this->Format->fontIcon('signin', ['size' => 5, 'extra' => ['muted'], 'namespace' => 'icon']);
151-
$expected = '<i class="icon-signin icon-muted icon-5x"></i>';
155+
$expected = '<i class="icon icon-signin icon-muted icon-5x"></i>';
152156
$this->assertEquals($expected, $result);
153157
}
154158

@@ -504,7 +508,7 @@ public function testWordCensor() {
504508
$res = $this->Format->wordCensor($value, ['Arsch', 'Ficken', 'Bitch']);
505509
$this->assertEquals($expected === null ? $value : $expected, $res);
506510
}
507-
511+
508512
$input = 'dfssdfsdj sdkfj sdkfj ksdfj bitch ksdfj';
509513
$result = $this->Format->wordCensor($input, ['Bitch'], '***');
510514
$expected = 'dfssdfsdj sdkfj sdkfj ksdfj *** ksdfj';

View/Helper/FormatHelper.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,9 @@ public function fontIcon($icon, array $options = [], array $attributes = []) {
315315
];
316316
$options += $defaults;
317317
$icon = (array)$icon;
318-
$class = [];
318+
$class = [
319+
$options['namespace']
320+
];
319321
foreach ($icon as $i) {
320322
$class[] = $options['namespace'] . '-' . $i;
321323
}

0 commit comments

Comments
 (0)