Skip to content

Commit

Permalink
fix indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
cebe committed Apr 2, 2019
1 parent ca08af1 commit 0f136db
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 46 deletions.
28 changes: 14 additions & 14 deletions framework/web/CHttpRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1025,20 +1025,20 @@ public function getPreferredAcceptType()
return empty($preferredAcceptTypes) ? false : $preferredAcceptTypes[0];
}

/**
* String compare function used by usort.
* Included to circumvent the use of closures (not supported by PHP 5.2) and create_function (deprecated since PHP 7.2.0)
* @param array $a
* @param array $b
* @return int -1 (a>b), 0 (a==b), 1 (a<b)
*/
private function stringCompare($a, $b)
{
if ($a[0] == $b[0]) {
return 0;
}
return ($a[0] < $b[0]) ? 1 : -1;
}
/**
* String compare function used by usort.
* Included to circumvent the use of closures (not supported by PHP 5.2) and create_function (deprecated since PHP 7.2.0)
* @param array $a
* @param array $b
* @return int -1 (a>b), 0 (a==b), 1 (a<b)
*/
private function stringCompare($a, $b)
{
if ($a[0] == $b[0]) {
return 0;
}
return ($a[0] < $b[0]) ? 1 : -1;
}

/**
* Returns an array of user accepted languages in order of preference.
Expand Down
2 changes: 1 addition & 1 deletion framework/web/helpers/CJavaScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CJavaScript
public static function quote($js,$forUrl=false)
{
$js = (string)$js;

Yii::import('system.vendors.zend-escaper.Escaper');
$escaper=new Escaper(Yii::app()->charset);
if($forUrl)
Expand Down
62 changes: 31 additions & 31 deletions tests/framework/web/helpers/CJavaScriptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,38 @@ public function testLegacyEncodeSafe()
$this->assertEquals("'js\\x3Afunction\\x28\\x29\\x20\\x7B\\x20\\x2F\\x2A\\x20callback\\x20\\x2A\\x2F\\x20\\x7D'",$expression);
}

public function testEncode()
{
$expression=CJavaScript::encode(new CJavaScriptExpression("function() { /* callback */ }"));
$this->assertEquals("function() { /* callback */ }",$expression);
}
public function testEncode()
{
$expression=CJavaScript::encode(new CJavaScriptExpression("function() { /* callback */ }"));
$this->assertEquals("function() { /* callback */ }",$expression);
}

private function getUnicodeTestString()
{
$unicodeChar1 = json_decode('"'.'\u2028'.'"');
$unicodeChar2 = json_decode('"'.'\u2029'.'"');
return "test {$unicodeChar1}\ntest $unicodeChar2";
}
private function getUnicodeTestString()
{
$unicodeChar1 = json_decode('"'.'\u2028'.'"');
$unicodeChar2 = json_decode('"'.'\u2029'.'"');
return "test {$unicodeChar1}\ntest $unicodeChar2";
}

public function testQuote()
{
$input=$this->getUnicodeTestString();
$output=CJavaScript::quote($input);
$this->assertEquals('test\x20\u2028\x0Atest\x20\u2029',$output);
}
public function testQuote()
{
$input=$this->getUnicodeTestString();
$output=CJavaScript::quote($input);
$this->assertEquals('test\x20\u2028\x0Atest\x20\u2029',$output);
}

public function testQuoteForUrl()
{
$input=$this->getUnicodeTestString();
$output=CJavaScript::quote($input,true);
$this->assertEquals('test%20%E2%80%A8%0Atest%20%E2%80%A9',$output);
}

public function testQuoteWithNull()
{
$input=null;
$output=CJavaScript::quote($input);
$this->assertSame('',$output);
}

public function testQuoteForUrl()
{
$input=$this->getUnicodeTestString();
$output=CJavaScript::quote($input,true);
$this->assertEquals('test%20%E2%80%A8%0Atest%20%E2%80%A9',$output);
}

public function testQuoteWithNull()
{
$input=null;
$output=CJavaScript::quote($input);
$this->assertSame('',$output);
}

}

0 comments on commit 0f136db

Please sign in to comment.