@@ -15,5 +15,5 @@ |
||
| 15 | 15 | * |
| 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 |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | * @inheritDoc |
| 37 | 37 | */ |
| 38 | - public function transform( string $segment ): string { |
|
| 38 | + public function transform(string $segment): string { |
|
| 39 | 39 | |
| 40 | 40 | // $sprintfLocker = new SprintfLocker( $this->pipeline->getSource(), $this->pipeline->getTarget() ); |
| 41 | 41 | |
@@ -43,12 +43,12 @@ discard block |
||
| 43 | 43 | // $segment = $sprintfLocker->lock( $segment ); |
| 44 | 44 | |
| 45 | 45 | |
| 46 | - preg_match_all( '/%\d+\$@|%@/', $segment, $html, PREG_SET_ORDER ); |
|
| 47 | - foreach ( $html as $percentNumberSnailVariable ) { |
|
| 46 | + preg_match_all('/%\d+\$@|%@/', $segment, $html, PREG_SET_ORDER); |
|
| 47 | + foreach ($html as $percentNumberSnailVariable) { |
|
| 48 | 48 | |
| 49 | 49 | $segment = preg_replace( |
| 50 | - '/' . preg_quote( $percentNumberSnailVariable[ 0 ], '/' ) . '/', |
|
| 51 | - '<ph id="' . $this->getPipeline()->getNextId() . '" ctype="' . CTypeEnum::OBJECTIVE_C_NSSTRING . '" equiv-text="base64:' . base64_encode( $percentNumberSnailVariable[ 0 ] ) . '"/>', |
|
| 50 | + '/'.preg_quote($percentNumberSnailVariable[0], '/').'/', |
|
| 51 | + '<ph id="'.$this->getPipeline()->getNextId().'" ctype="'.CTypeEnum::OBJECTIVE_C_NSSTRING.'" equiv-text="base64:'.base64_encode($percentNumberSnailVariable[0]).'"/>', |
|
| 52 | 52 | $segment, |
| 53 | 53 | 1 |
| 54 | 54 | ); |
@@ -14,39 +14,39 @@ |
||
| 14 | 14 | |
| 15 | 15 | class PlaceHoldXliffTags extends AbstractHandler { |
| 16 | 16 | |
| 17 | - public function transform( string $segment ): string { |
|
| 17 | + public function transform(string $segment): string { |
|
| 18 | 18 | |
| 19 | 19 | // input : <g id="43">bang & < 3 olufsen </g>; <x id="33"/> |
| 20 | 20 | |
| 21 | 21 | //remove not existent </x> tags |
| 22 | - $segment = preg_replace( '|(</x>)|si', "", $segment ); |
|
| 23 | - |
|
| 24 | - $segment = preg_replace( '|<(g\s*.*?)>|si', ConstantEnum::LTPLACEHOLDER . "$1" . ConstantEnum::GTPLACEHOLDER, $segment ); |
|
| 25 | - $segment = preg_replace( '|<(/g)>|si', ConstantEnum::LTPLACEHOLDER . "$1" . ConstantEnum::GTPLACEHOLDER, $segment ); |
|
| 26 | - |
|
| 27 | - $segment = preg_replace( '|<(x .*?/?)>|si', ConstantEnum::LTPLACEHOLDER . "$1" . ConstantEnum::GTPLACEHOLDER, $segment ); |
|
| 28 | - $segment = preg_replace( '#<(bx */?|bx .*?/?)>#si', ConstantEnum::LTPLACEHOLDER . "$1" . ConstantEnum::GTPLACEHOLDER, $segment ); |
|
| 29 | - $segment = preg_replace( '#<(ex */?|ex .*?/?)>#si', ConstantEnum::LTPLACEHOLDER . "$1" . ConstantEnum::GTPLACEHOLDER, $segment ); |
|
| 30 | - $segment = preg_replace( '|<(bpt\s*.*?)>|si', ConstantEnum::LTPLACEHOLDER . "$1" . ConstantEnum::GTPLACEHOLDER, $segment ); |
|
| 31 | - $segment = preg_replace( '|<(/bpt)>|si', ConstantEnum::LTPLACEHOLDER . "$1" . ConstantEnum::GTPLACEHOLDER, $segment ); |
|
| 32 | - $segment = preg_replace( '|<(ept\s*.*?)>|si', ConstantEnum::LTPLACEHOLDER . "$1" . ConstantEnum::GTPLACEHOLDER, $segment ); |
|
| 33 | - $segment = preg_replace( '|<(/ept)>|si', ConstantEnum::LTPLACEHOLDER . "$1" . ConstantEnum::GTPLACEHOLDER, $segment ); |
|
| 34 | - $segment = preg_replace( '|<(ph .*?)>|si', ConstantEnum::LTPLACEHOLDER . "$1" . ConstantEnum::GTPLACEHOLDER, $segment ); |
|
| 35 | - $segment = preg_replace( '|<(/ph)>|si', ConstantEnum::LTPLACEHOLDER . "$1" . ConstantEnum::GTPLACEHOLDER, $segment ); |
|
| 36 | - $segment = preg_replace( '|<(ec .*?)>|si', ConstantEnum::LTPLACEHOLDER . "$1" . ConstantEnum::GTPLACEHOLDER, $segment ); |
|
| 37 | - $segment = preg_replace( '|<(/ec)>|si', ConstantEnum::LTPLACEHOLDER . "$1" . ConstantEnum::GTPLACEHOLDER, $segment ); |
|
| 38 | - $segment = preg_replace( '|<(sc .*?)>|si', ConstantEnum::LTPLACEHOLDER . "$1" . ConstantEnum::GTPLACEHOLDER, $segment ); |
|
| 39 | - $segment = preg_replace( '|<(/sc)>|si', ConstantEnum::LTPLACEHOLDER . "$1" . ConstantEnum::GTPLACEHOLDER, $segment ); |
|
| 40 | - $segment = preg_replace( '|<(pc .*?)>|si', ConstantEnum::LTPLACEHOLDER . "$1" . ConstantEnum::GTPLACEHOLDER, $segment ); |
|
| 41 | - $segment = preg_replace( '|<(/pc)>|si', ConstantEnum::LTPLACEHOLDER . "$1" . ConstantEnum::GTPLACEHOLDER, $segment ); |
|
| 42 | - $segment = preg_replace( '|<(it .*?)>|si', ConstantEnum::LTPLACEHOLDER . "$1" . ConstantEnum::GTPLACEHOLDER, $segment ); |
|
| 43 | - $segment = preg_replace( '|<(/it)>|si', ConstantEnum::LTPLACEHOLDER . "$1" . ConstantEnum::GTPLACEHOLDER, $segment ); |
|
| 44 | - $segment = preg_replace( '|<(mrk\s*.*?)>|si', ConstantEnum::LTPLACEHOLDER . "$1" . ConstantEnum::GTPLACEHOLDER, $segment ); |
|
| 45 | - $segment = preg_replace( '|<(/mrk)>|si', ConstantEnum::LTPLACEHOLDER . "$1" . ConstantEnum::GTPLACEHOLDER, $segment ); |
|
| 46 | - |
|
| 47 | - return preg_replace_callback( '/' . ConstantEnum::LTPLACEHOLDER . '(.*?)' . ConstantEnum::GTPLACEHOLDER . '/u', |
|
| 48 | - function ( $matches ) { |
|
| 49 | - return ConstantEnum::LTPLACEHOLDER . base64_encode( $matches[ 1 ] ) . ConstantEnum::GTPLACEHOLDER; |
|
| 22 | + $segment = preg_replace('|(</x>)|si', "", $segment); |
|
| 23 | + |
|
| 24 | + $segment = preg_replace('|<(g\s*.*?)>|si', ConstantEnum::LTPLACEHOLDER."$1".ConstantEnum::GTPLACEHOLDER, $segment); |
|
| 25 | + $segment = preg_replace('|<(/g)>|si', ConstantEnum::LTPLACEHOLDER."$1".ConstantEnum::GTPLACEHOLDER, $segment); |
|
| 26 | + |
|
| 27 | + $segment = preg_replace('|<(x .*?/?)>|si', ConstantEnum::LTPLACEHOLDER."$1".ConstantEnum::GTPLACEHOLDER, $segment); |
|
| 28 | + $segment = preg_replace('#<(bx */?|bx .*?/?)>#si', ConstantEnum::LTPLACEHOLDER."$1".ConstantEnum::GTPLACEHOLDER, $segment); |
|
| 29 | + $segment = preg_replace('#<(ex */?|ex .*?/?)>#si', ConstantEnum::LTPLACEHOLDER."$1".ConstantEnum::GTPLACEHOLDER, $segment); |
|
| 30 | + $segment = preg_replace('|<(bpt\s*.*?)>|si', ConstantEnum::LTPLACEHOLDER."$1".ConstantEnum::GTPLACEHOLDER, $segment); |
|
| 31 | + $segment = preg_replace('|<(/bpt)>|si', ConstantEnum::LTPLACEHOLDER."$1".ConstantEnum::GTPLACEHOLDER, $segment); |
|
| 32 | + $segment = preg_replace('|<(ept\s*.*?)>|si', ConstantEnum::LTPLACEHOLDER."$1".ConstantEnum::GTPLACEHOLDER, $segment); |
|
| 33 | + $segment = preg_replace('|<(/ept)>|si', ConstantEnum::LTPLACEHOLDER."$1".ConstantEnum::GTPLACEHOLDER, $segment); |
|
| 34 | + $segment = preg_replace('|<(ph .*?)>|si', ConstantEnum::LTPLACEHOLDER."$1".ConstantEnum::GTPLACEHOLDER, $segment); |
|
| 35 | + $segment = preg_replace('|<(/ph)>|si', ConstantEnum::LTPLACEHOLDER."$1".ConstantEnum::GTPLACEHOLDER, $segment); |
|
| 36 | + $segment = preg_replace('|<(ec .*?)>|si', ConstantEnum::LTPLACEHOLDER."$1".ConstantEnum::GTPLACEHOLDER, $segment); |
|
| 37 | + $segment = preg_replace('|<(/ec)>|si', ConstantEnum::LTPLACEHOLDER."$1".ConstantEnum::GTPLACEHOLDER, $segment); |
|
| 38 | + $segment = preg_replace('|<(sc .*?)>|si', ConstantEnum::LTPLACEHOLDER."$1".ConstantEnum::GTPLACEHOLDER, $segment); |
|
| 39 | + $segment = preg_replace('|<(/sc)>|si', ConstantEnum::LTPLACEHOLDER."$1".ConstantEnum::GTPLACEHOLDER, $segment); |
|
| 40 | + $segment = preg_replace('|<(pc .*?)>|si', ConstantEnum::LTPLACEHOLDER."$1".ConstantEnum::GTPLACEHOLDER, $segment); |
|
| 41 | + $segment = preg_replace('|<(/pc)>|si', ConstantEnum::LTPLACEHOLDER."$1".ConstantEnum::GTPLACEHOLDER, $segment); |
|
| 42 | + $segment = preg_replace('|<(it .*?)>|si', ConstantEnum::LTPLACEHOLDER."$1".ConstantEnum::GTPLACEHOLDER, $segment); |
|
| 43 | + $segment = preg_replace('|<(/it)>|si', ConstantEnum::LTPLACEHOLDER."$1".ConstantEnum::GTPLACEHOLDER, $segment); |
|
| 44 | + $segment = preg_replace('|<(mrk\s*.*?)>|si', ConstantEnum::LTPLACEHOLDER."$1".ConstantEnum::GTPLACEHOLDER, $segment); |
|
| 45 | + $segment = preg_replace('|<(/mrk)>|si', ConstantEnum::LTPLACEHOLDER."$1".ConstantEnum::GTPLACEHOLDER, $segment); |
|
| 46 | + |
|
| 47 | + return preg_replace_callback('/'.ConstantEnum::LTPLACEHOLDER.'(.*?)'.ConstantEnum::GTPLACEHOLDER.'/u', |
|
| 48 | + function($matches) { |
|
| 49 | + return ConstantEnum::LTPLACEHOLDER.base64_encode($matches[1]).ConstantEnum::GTPLACEHOLDER; |
|
| 50 | 50 | }, $segment |
| 51 | 51 | ); //base64 of the tag content to avoid unwanted manipulation |
| 52 | 52 | } |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | */ |
| 43 | 43 | public function transform( string $segment ): string { |
| 44 | 44 | |
| 45 | - // disabled for now, we want to check if this is really needed |
|
| 45 | + // disabled for now, we want to check if this is really needed |
|
| 46 | 46 | // $sprintfLocker = new SprintfLocker( $this->pipeline->getSource(), $this->pipeline->getTarget() ); |
| 47 | 47 | |
| 48 | 48 | // placeholding |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * - https://www.w3resource.com/c-programming/stdio/c_library_method_sprintf.php |
| 41 | 41 | * |
| 42 | 42 | */ |
| 43 | - public function transform( string $segment ): string { |
|
| 43 | + public function transform(string $segment): string { |
|
| 44 | 44 | |
| 45 | 45 | // disabled for now, we want to check if this is really needed |
| 46 | 46 | // $sprintfLocker = new SprintfLocker( $this->pipeline->getSource(), $this->pipeline->getTarget() ); |
@@ -52,13 +52,13 @@ discard block |
||
| 52 | 52 | $regex = '/(?:\x25\x25)|(\x25(?:(?:[1-9]\d*)\$|\((?:[^)]+)\))?(?:\+)?(?:0|[+-]?\'[^$])?(?:-)?(?:\d+)?(?:\.(?:\d+))?((?:[hjlqtzL]{0,2}[a-iopsuxAC-HOSUX])))/'; |
| 53 | 53 | |
| 54 | 54 | |
| 55 | - preg_match_all( $regex, $segment, $vars, PREG_SET_ORDER ); |
|
| 56 | - foreach ( $vars as $variable ) { |
|
| 55 | + preg_match_all($regex, $segment, $vars, PREG_SET_ORDER); |
|
| 56 | + foreach ($vars as $variable) { |
|
| 57 | 57 | |
| 58 | 58 | //replace subsequent elements excluding already encoded |
| 59 | 59 | $segment = preg_replace( |
| 60 | - '/' . preg_quote( $variable[ 0 ], '/' ) . '/', |
|
| 61 | - '<ph id="' . $this->getPipeline()->getNextId() . '" ctype="' . CTypeEnum::SPRINTF . '" equiv-text="base64:' . base64_encode( $variable[ 0 ] ) . '"/>', |
|
| 60 | + '/'.preg_quote($variable[0], '/').'/', |
|
| 61 | + '<ph id="'.$this->getPipeline()->getNextId().'" ctype="'.CTypeEnum::SPRINTF.'" equiv-text="base64:'.base64_encode($variable[0]).'"/>', |
|
| 62 | 62 | $segment, |
| 63 | 63 | 1 |
| 64 | 64 | ); |