@@ -15,5 +15,5 @@ |
||
15 | 15 | * modified in cascade to the next function in the queue. |
16 | 16 | * @throws \Exception |
17 | 17 | */ |
18 | - public function filter( $method, $filterable ); |
|
18 | + public function filter($method, $filterable); |
|
19 | 19 | } |
20 | 20 | \ No newline at end of file |
@@ -43,31 +43,31 @@ |
||
43 | 43 | * |
44 | 44 | * @return string |
45 | 45 | */ |
46 | - public function transform( $segment ) { |
|
46 | + public function transform($segment) { |
|
47 | 47 | |
48 | - $sprintfLocker = new SprintfLocker( $this->pipeline->getSource(), $this->pipeline->getTarget() ); |
|
48 | + $sprintfLocker = new SprintfLocker($this->pipeline->getSource(), $this->pipeline->getTarget()); |
|
49 | 49 | |
50 | 50 | // placeholding |
51 | - $segment = $sprintfLocker->lock( $segment ); |
|
51 | + $segment = $sprintfLocker->lock($segment); |
|
52 | 52 | |
53 | 53 | // Octal parsing is disabled due to Hungarian percentages 20%-os |
54 | 54 | $regex = '/(?:\x25\x25)|(\x25(?:(?:[1-9]\d*)\$|\((?:[^\)]+)\))?(?:\+)?(?:0|[+-]?\'[^$])?(?:-)?(?:\d+)?(?:\.(?:\d+))?((?:[hjlqtzL]{0,2}[ac-giopsuxAC-GOSUX]{1})(?![\d\w])|(?:#@[\w]+@)|(?:@)))/'; |
55 | 55 | |
56 | 56 | |
57 | - preg_match_all( $regex, $segment, $vars, PREG_SET_ORDER ); |
|
58 | - foreach ( $vars as $pos => $variable ) { |
|
57 | + preg_match_all($regex, $segment, $vars, PREG_SET_ORDER); |
|
58 | + foreach ($vars as $pos => $variable) { |
|
59 | 59 | |
60 | 60 | //replace subsequent elements excluding already encoded |
61 | 61 | $segment = preg_replace( |
62 | - '/' . preg_quote( $variable[ 0 ], '/' ) . '/', |
|
63 | - '<ph id="__mtc_' . $this->getPipeline()->getNextId() . '" ctype="' . CTypeEnum::SPRINTF . '" equiv-text="base64:' . base64_encode( $variable[ 0 ] ) . '"/>', |
|
62 | + '/'.preg_quote($variable[0], '/').'/', |
|
63 | + '<ph id="__mtc_'.$this->getPipeline()->getNextId().'" ctype="'.CTypeEnum::SPRINTF.'" equiv-text="base64:'.base64_encode($variable[0]).'"/>', |
|
64 | 64 | $segment, |
65 | 65 | 1 |
66 | 66 | ); |
67 | 67 | } |
68 | 68 | |
69 | 69 | //revert placeholding |
70 | - $segment = $sprintfLocker->unlock( $segment ); |
|
70 | + $segment = $sprintfLocker->unlock($segment); |
|
71 | 71 | |
72 | 72 | return $segment; |
73 | 73 | } |
@@ -10,25 +10,25 @@ |
||
10 | 10 | /** |
11 | 11 | * @inheritDoc |
12 | 12 | */ |
13 | - public function transform( $segment ) { |
|
13 | + public function transform($segment) { |
|
14 | 14 | |
15 | - $sprintfLocker = new SprintfLocker( $this->pipeline->getSource(), $this->pipeline->getTarget() ); |
|
15 | + $sprintfLocker = new SprintfLocker($this->pipeline->getSource(), $this->pipeline->getTarget()); |
|
16 | 16 | |
17 | 17 | //placeholding |
18 | - $segment = $sprintfLocker->lock( $segment ); |
|
18 | + $segment = $sprintfLocker->lock($segment); |
|
19 | 19 | |
20 | - preg_match_all( '/%@/', $segment, $html, PREG_SET_ORDER ); |
|
21 | - foreach ( $html as $pos => $percentSnailVariable ) { |
|
20 | + preg_match_all('/%@/', $segment, $html, PREG_SET_ORDER); |
|
21 | + foreach ($html as $pos => $percentSnailVariable) { |
|
22 | 22 | |
23 | 23 | $segment = preg_replace( |
24 | - '/' . preg_quote( $percentSnailVariable[ 0 ], '/' ) . '/', |
|
25 | - '<ph id="__mtc_' . $this->getPipeline()->getNextId() . '" ctype="' . CTypeEnum::PERCENT_SNAILS . '" equiv-text="base64:' . base64_encode( $percentSnailVariable[ 0 ] ) . '"/>', |
|
24 | + '/'.preg_quote($percentSnailVariable[0], '/').'/', |
|
25 | + '<ph id="__mtc_'.$this->getPipeline()->getNextId().'" ctype="'.CTypeEnum::PERCENT_SNAILS.'" equiv-text="base64:'.base64_encode($percentSnailVariable[0]).'"/>', |
|
26 | 26 | $segment, |
27 | 27 | 1 |
28 | 28 | ); |
29 | 29 | } |
30 | 30 | |
31 | - $segment = $sprintfLocker->unlock( $segment ); |
|
31 | + $segment = $sprintfLocker->unlock($segment); |
|
32 | 32 | |
33 | 33 | return $segment; |
34 | 34 | } |
@@ -14,7 +14,7 @@ |
||
14 | 14 | |
15 | 15 | class SpecialEntitiesToPlaceholdersForView extends AbstractHandler { |
16 | 16 | |
17 | - public function transform( $segment ) { |
|
17 | + public function transform($segment) { |
|
18 | 18 | |
19 | 19 | $segment = str_ireplace( |
20 | 20 | [ |
@@ -32,15 +32,15 @@ |
||
32 | 32 | * |
33 | 33 | * @return string |
34 | 34 | */ |
35 | - public function transform( $segment ) { |
|
36 | - preg_match_all( '/{[^<>{} ]+?}/', $segment, $html, PREG_SET_ORDER ); |
|
37 | - foreach ( $html as $pos => $twig_variable ) { |
|
35 | + public function transform($segment) { |
|
36 | + preg_match_all('/{[^<>{} ]+?}/', $segment, $html, PREG_SET_ORDER); |
|
37 | + foreach ($html as $pos => $twig_variable) { |
|
38 | 38 | //check if inside twig variable there is a tag because in this case shouldn't replace the content with PH tag |
39 | - if ( !strstr( $twig_variable[ 0 ], ConstantEnum::GTPLACEHOLDER ) ) { |
|
39 | + if (!strstr($twig_variable[0], ConstantEnum::GTPLACEHOLDER)) { |
|
40 | 40 | //replace subsequent elements excluding already encoded |
41 | 41 | $segment = preg_replace( |
42 | - '/' . preg_quote( $twig_variable[ 0 ], '/' ) . '/', |
|
43 | - '<ph id="__mtc_' . $this->getPipeline()->getNextId() . '" ctype="' . CTypeEnum::CURLY_BRACKETS . '" equiv-text="base64:' . base64_encode( $twig_variable[ 0 ] ) . '"/>', |
|
42 | + '/'.preg_quote($twig_variable[0], '/').'/', |
|
43 | + '<ph id="__mtc_'.$this->getPipeline()->getNextId().'" ctype="'.CTypeEnum::CURLY_BRACKETS.'" equiv-text="base64:'.base64_encode($twig_variable[0]).'"/>', |
|
44 | 44 | $segment, |
45 | 45 | 1 |
46 | 46 | ); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @return mixed |
33 | 33 | */ |
34 | - protected function _finalizePlainText( $buffer ) { |
|
34 | + protected function _finalizePlainText($buffer) { |
|
35 | 35 | return $buffer; |
36 | 36 | } |
37 | 37 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return string |
42 | 42 | */ |
43 | - protected function _finalizeHTMLTag( $buffer ) { |
|
43 | + protected function _finalizeHTMLTag($buffer) { |
|
44 | 44 | //decode attributes by locking <,> first |
45 | 45 | //because a html tag has it's attributes encoded and here we get lt and gt decoded but not other parts of the string |
46 | 46 | // Ex: |
@@ -48,11 +48,11 @@ discard block |
||
48 | 48 | // this should be: <a href="/users/settings?test=123&ciccio=1" target="_blank"> with only one ampersand encoding |
49 | 49 | // |
50 | 50 | |
51 | - $buffer = str_replace( [ '<', '>' ], [ '#_lt_#', '#_gt_#' ], $buffer ); |
|
52 | - $buffer = html_entity_decode( $buffer, ENT_NOQUOTES | 16 /* ENT_XML1 */, 'UTF-8' ); |
|
53 | - $buffer = str_replace( [ '#_lt_#', '#_gt_#' ], [ '<', '>' ], $buffer ); |
|
51 | + $buffer = str_replace(['<', '>'], ['#_lt_#', '#_gt_#'], $buffer); |
|
52 | + $buffer = html_entity_decode($buffer, ENT_NOQUOTES | 16 /* ENT_XML1 */, 'UTF-8'); |
|
53 | + $buffer = str_replace(['#_lt_#', '#_gt_#'], ['<', '>'], $buffer); |
|
54 | 54 | |
55 | - return $this->_finalizeTag( $buffer ); |
|
55 | + return $this->_finalizeTag($buffer); |
|
56 | 56 | |
57 | 57 | } |
58 | 58 | |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @return string |
63 | 63 | */ |
64 | - protected function _finalizeTag( $buffer ) { |
|
65 | - return '<ph id="__mtc_' . $this->getPipeline()->getNextId() . '" ctype="' . CTypeEnum::HTML . '" equiv-text="base64:' . base64_encode( htmlentities( $buffer, ENT_NOQUOTES | 16 /* ENT_XML1 */ ) ) . '"/>'; |
|
64 | + protected function _finalizeTag($buffer) { |
|
65 | + return '<ph id="__mtc_'.$this->getPipeline()->getNextId().'" ctype="'.CTypeEnum::HTML.'" equiv-text="base64:'.base64_encode(htmlentities($buffer, ENT_NOQUOTES | 16 /* ENT_XML1 */)).'"/>'; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @return mixed |
72 | 72 | */ |
73 | - protected function _fixWrongBuffer( $buffer ) { |
|
74 | - $buffer = str_replace( "<", "<", $buffer ); |
|
75 | - $buffer = str_replace( ">", ">", $buffer ); |
|
73 | + protected function _fixWrongBuffer($buffer) { |
|
74 | + $buffer = str_replace("<", "<", $buffer); |
|
75 | + $buffer = str_replace(">", ">", $buffer); |
|
76 | 76 | |
77 | 77 | return $buffer; |
78 | 78 | } |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @return string |
84 | 84 | */ |
85 | - protected function _finalizeScriptTag( $buffer ) { |
|
86 | - return $this->_finalizeTag( $buffer ); |
|
85 | + protected function _finalizeScriptTag($buffer) { |
|
86 | + return $this->_finalizeTag($buffer); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @return bool |
99 | 99 | */ |
100 | - protected function _isTagValid( $buffer ) { |
|
100 | + protected function _isTagValid($buffer) { |
|
101 | 101 | |
102 | 102 | /* |
103 | 103 | * accept tags start with: |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * - ending with a letter a-zA-Z0-9 or a quote "' or / |
108 | 108 | * |
109 | 109 | */ |
110 | - if ( preg_match( '#<[/]{0,1}(?![0-9]+)[a-z0-9\-\._:]+?(?:\s[:a-z0-9\-\._]+=.+?)?\s*[\/]{0,1}>#is', $buffer ) ) { |
|
110 | + if (preg_match('#<[/]{0,1}(?![0-9]+)[a-z0-9\-\._:]+?(?:\s[:a-z0-9\-\._]+=.+?)?\s*[\/]{0,1}>#is', $buffer)) { |
|
111 | 111 | // if( is_numeric( substr( $buffer, -2, 1 ) ) && !preg_match( '#<[/]{0,1}[h][1-6][^>]*>#is', $buffer ) ){ //H tag are an exception |
112 | 112 | // //tag can not end with a number |
113 | 113 | // return false; |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | //EX: |
118 | 118 | //original: <a href=\"<x id="1">\"> |
119 | 119 | // <a href=\"##LESSTHAN##eCBpZD0iMSIv##GREATERTHAN##\"> |
120 | - if ( strpos( $buffer, ConstantEnum::LTPLACEHOLDER ) !== false || strpos( $buffer, ConstantEnum::GTPLACEHOLDER ) !== false ) { |
|
120 | + if (strpos($buffer, ConstantEnum::LTPLACEHOLDER) !== false || strpos($buffer, ConstantEnum::GTPLACEHOLDER) !== false) { |
|
121 | 121 | return false; |
122 | 122 | } |
123 | 123 | |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | * |
134 | 134 | * @return string |
135 | 135 | */ |
136 | - public function transform( $segment ) { |
|
136 | + public function transform($segment) { |
|
137 | 137 | $parser = new HtmlParser(); |
138 | - $parser->registerCallbacksHandler( $this ); |
|
138 | + $parser->registerCallbacksHandler($this); |
|
139 | 139 | |
140 | - return $parser->transform( $segment ); |
|
140 | + return $parser->transform($segment); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | } |
144 | 144 | \ No newline at end of file |
@@ -11,17 +11,17 @@ |
||
11 | 11 | * |
12 | 12 | * @return string |
13 | 13 | */ |
14 | - public function transform( $segment ) { |
|
14 | + public function transform($segment) { |
|
15 | 15 | /* |
16 | 16 | * Examples: |
17 | 17 | * - [AIRBNB] Reminder: Reply to %{guest}’s inquiry. |||| [AIRBNB] Reminder: Reply to %{guest}’s inquiry. |
18 | 18 | */ |
19 | - preg_match_all( '/(\|\|\|\|)/', $segment, $html, PREG_SET_ORDER ); |
|
20 | - foreach ( $html as $pos => $variable ) { |
|
19 | + preg_match_all('/(\|\|\|\|)/', $segment, $html, PREG_SET_ORDER); |
|
20 | + foreach ($html as $pos => $variable) { |
|
21 | 21 | //replace subsequent elements excluding already encoded |
22 | 22 | $segment = preg_replace( |
23 | - '/' . preg_quote( $variable[ 0 ], '/' ) . '/', |
|
24 | - '<ph id="__mtc_' . $this->getPipeline()->getNextId() . '" ctype="' . CTypeEnum::SMART_COUNT . '" equiv-text="base64:' . base64_encode( $variable[ 0 ] ) . "\"/>", |
|
23 | + '/'.preg_quote($variable[0], '/').'/', |
|
24 | + '<ph id="__mtc_'.$this->getPipeline()->getNextId().'" ctype="'.CTypeEnum::SMART_COUNT.'" equiv-text="base64:'.base64_encode($variable[0])."\"/>", |
|
25 | 25 | $segment, |
26 | 26 | 1 |
27 | 27 | ); |
@@ -6,10 +6,10 @@ |
||
6 | 6 | |
7 | 7 | class LtGtEncode extends AbstractHandler { |
8 | 8 | |
9 | - public function transform( $segment ) { |
|
9 | + public function transform($segment) { |
|
10 | 10 | // restore < e > |
11 | - $segment = str_replace( "<", "<", $segment ); |
|
12 | - $segment = str_replace( ">", ">", $segment ); |
|
11 | + $segment = str_replace("<", "<", $segment); |
|
12 | + $segment = str_replace(">", ">", $segment); |
|
13 | 13 | |
14 | 14 | return $segment; |
15 | 15 | } |
@@ -14,8 +14,8 @@ |
||
14 | 14 | |
15 | 15 | class EmojiToEntity extends AbstractHandler { |
16 | 16 | |
17 | - public function transform( $segment ) { |
|
18 | - return Emoji::toEntity( $segment ); |
|
17 | + public function transform($segment) { |
|
18 | + return Emoji::toEntity($segment); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | } |
22 | 22 | \ No newline at end of file |