diff --git a/src/Commons/Pipeline.php b/src/Commons/Pipeline.php index e3a7010..8f275d5 100644 --- a/src/Commons/Pipeline.php +++ b/src/Commons/Pipeline.php @@ -142,6 +142,7 @@ public function remove( AbstractHandler $handlerToDelete ) { foreach ( $this->handlers as $pos => $handler ) { if ( $handler->getName() == $handlerToDelete->getName() ) { unset( $this->handlers[ $pos ] ); + $this->handlers = array_values( $this->handlers ); break; } } diff --git a/src/Filters/DataRefRestore.php b/src/Filters/DataRefRestore.php index a7e1a5e..fcd9196 100644 --- a/src/Filters/DataRefRestore.php +++ b/src/Filters/DataRefRestore.php @@ -59,7 +59,7 @@ public function transform( $segment ) { * @return string */ private function restoreXliffPhTagsFromMatecatPhTags( $segment ) { - preg_match_all( '||iu', $segment, $matches ); + preg_match_all( '|]+? ctype="' . CTypeEnum::ORIGINAL_PH_OR_NOT_DATA_REF . '" equiv-text="base64:(.*?)"/>|iu', $segment, $matches ); if ( empty( $matches[ 0 ] ) ) { return $segment; @@ -89,8 +89,13 @@ private function restoreXliffPhTagsFromMatecatPhTags( $segment ) { * @return string */ private function restoreXliffPcTagsFromMatecatPhTags( $segment ) { - preg_match_all( '||iu', $segment, $matches ); - preg_match_all( '||iu', $segment, $matches ); + + $matches = []; + preg_match_all( '|]+? ctype="' . CTypeEnum::ORIGINAL_PC_OPEN_NO_DATA_REF . '" equiv-text="base64:(.*?)"/>|iu', $segment, $open_matches ); + preg_match_all( '|]+? ctype="' . CTypeEnum::ORIGINAL_PC_CLOSE_NO_DATA_REF . '" equiv-text="base64:(.*?)"/>|iu', $segment, $close_matches ); + + $matches[ 0 ] = array_merge( $open_matches[ 0 ], $close_matches[ 0 ] ); + $matches[ 1 ] = array_merge( $open_matches[ 1 ], $close_matches[ 1 ] ); if ( empty( $matches[ 0 ] ) ) { return $segment; diff --git a/src/Filters/Html/HtmlParser.php b/src/Filters/Html/HtmlParser.php index 1dc7084..253cd31 100644 --- a/src/Filters/Html/HtmlParser.php +++ b/src/Filters/Html/HtmlParser.php @@ -82,6 +82,9 @@ public function __call( $name, $arguments ) { return $reflector->invoke( $this->callbacksHandler, $arguments[ 0 ] ); } + + return null; + } public function transform( $segment ) { @@ -127,9 +130,6 @@ public function transform( $segment ) { // is not possible to have angle brackets inside a tag, this case can not happen // this code would ignore '>' if inside a quote, useless // for more info see https://www.w3.org/TR/xml/#charsets -// if ( $in_quote_char ) { -// break; -// } // if we found a second less than symbol the first one IS NOT a tag, // treat the html_buffer as plain text and attach to the output @@ -141,9 +141,6 @@ public function transform( $segment ) { // is not possible to have angle brackets inside a tag, this case can not happen // this code would ignore '>' if inside a quote, useless // for more info see https://www.w3.org/TR/xml/#charsets -// if ( $in_quote_char ) { -// break; -// } if ( in_array( substr( $html_buffer, 0, 8 ), [ '