Skip to content
This repository

[ZF2-170][Filter] Fix trim for cyrillic characters. #1451

Merged
merged 1 commit into from almost 2 years ago

3 participants

Maks Dolf Schimmel kazusuke sasezaki
Maks
Collaborator
Maks3w commented June 06, 2012

Build Status Apply SVN r16417

Dolf Schimmel
Collaborator

Thanks!

Dolf Schimmel Freeaqingme merged commit b5b146d into from June 06, 2012
Dolf Schimmel Freeaqingme closed this June 06, 2012
kazusuke sasezaki

.... this change is removing "u" qualifier.
But "u" qualifier comes from ZF-10891
http://framework.zend.com/issues/browse/ZF-10891
I don't know why @thomasweidner did apply this change only zf2.

This backporting wil be fix cyrillic characters.
But zenkaku space(multibyte space - Japanese special space char) will not trim.
https://gist.github.com/2881443

I hope someone will fix both ZF-10891 & cyrillic char issue correctly.

Maks
Collaborator
Maks3w commented June 06, 2012

@sasezaki Please reopen ZF2-170 with the test function and I will take a look later.

kazusuke sasezaki

@Maks3w thanks, catch up. I re-opend ZF-10891 (not ZF2-170)
http://framework.zend.com/issues/browse/ZF-10891

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jun 06, 2012
Maks [Filter] Fix trim for cyrillic characters.
Apply SVN r16417
75e8d47
This page is out of date. Refresh to see the latest.
2  library/Zend/Filter/StringTrim.php
@@ -123,6 +123,6 @@ protected function _unicodeTrim($value, $charlist = '\\\\s')
123 123
         );
124 124
 
125 125
         $pattern = '^[' . $chars . ']*|[' . $chars . ']*$';
126  
-        return preg_replace("/$pattern/usSD", '', $value);
  126
+        return preg_replace("/$pattern/sSD", '', $value);
127 127
     }
128 128
 }
30  tests/Zend/Filter/StringTrimTest.php
@@ -22,7 +22,7 @@
22 22
 namespace ZendTest\Filter;
23 23
 
24 24
 use stdClass;
25  
-use Zend\Filter\StringTrim as StringTrimFilter;
  25
+use Zend\Filter\StringTrim;
26 26
 
27 27
 /**
28 28
  * @category   Zend
@@ -35,20 +35,18 @@
35 35
 class StringTrimTest extends \PHPUnit_Framework_TestCase
36 36
 {
37 37
     /**
38  
-     * Zend_Filter_StringTrim object
39  
-     *
40  
-     * @var Zend_Filter_StringTrim
  38
+     * @var StringTrim
41 39
      */
42 40
     protected $_filter;
43 41
 
44 42
     /**
45  
-     * Creates a new Zend_Filter_StringTrim object for each test method
  43
+     * Creates a new Zend\Filter\StringTrim object for each test method
46 44
      *
47 45
      * @return void
48 46
      */
49 47
     public function setUp()
50 48
     {
51  
-        $this->_filter = new StringTrimFilter();
  49
+        $this->_filter = new StringTrim();
52 50
     }
53 51
 
54 52
     /**
@@ -103,7 +101,7 @@ public function testCharList()
103 101
     }
104 102
 
105 103
     /**
106  
-     * @ZF-7183
  104
+     * @group ZF-7183
107 105
      */
108 106
     public function testZF7183()
109 107
     {
@@ -112,7 +110,17 @@ public function testZF7183()
112 110
     }
113 111
 
114 112
     /**
115  
-     * @ZF-7902
  113
+     * @group ZF2-170
  114
+     */
  115
+    public function testZF2170()
  116
+    {
  117
+        $filter = $this->_filter;
  118
+        $this->assertEquals('Расчет', $filter('Расчет'));
  119
+    }
  120
+
  121
+
  122
+    /**
  123
+     * @group ZF-7902
116 124
      */
117 125
     public function testZF7902()
118 126
     {
@@ -121,7 +129,7 @@ public function testZF7902()
121 129
     }
122 130
 
123 131
     /**
124  
-     * @ZF-10891
  132
+     * @group ZF-10891
125 133
      */
126 134
     public function testZF10891()
127 135
     {
@@ -131,10 +139,8 @@ public function testZF10891()
131 139
         $this->assertEquals('Зенд', $filter('   Зенд'));
132 140
 
133 141
         $trim_charlist = " \t\n\r\x0B・。";
134  
-        $filter = new StringTrimFilter($trim_charlist);
  142
+        $filter = new StringTrim($trim_charlist);
135 143
         $this->assertEquals('Зенд', $filter->filter('。  Зенд  。'));
136  
-
137  
-
138 144
     }
139 145
 
140 146
     public function getNonStringValues()
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.