diff --git a/includes/optional-modules/indesign-export/class-indesign-converter.php b/includes/optional-modules/indesign-export/class-indesign-converter.php index 899148522a..2c6bd80e81 100644 --- a/includes/optional-modules/indesign-export/class-indesign-converter.php +++ b/includes/optional-modules/indesign-export/class-indesign-converter.php @@ -468,10 +468,10 @@ private function process_post_images( $post ) { $tag_content .= "\r\n"; if ( $caption ) { - $tag_content .= '' . $caption . "\r\n"; + $tag_content .= '' . $this->get_transformed_text( $caption ) . "\r\n"; } if ( $credit ) { - $tag_content .= '' . $credit . "\r\n"; + $tag_content .= '' . $this->get_transformed_text( $credit ) . "\r\n"; } } diff --git a/tests/unit-tests/indesign-exporter/indesign-exporter.php b/tests/unit-tests/indesign-exporter/indesign-exporter.php index 57092510c4..4ac4d2fc5c 100644 --- a/tests/unit-tests/indesign-exporter/indesign-exporter.php +++ b/tests/unit-tests/indesign-exporter/indesign-exporter.php @@ -277,4 +277,30 @@ public function test_convert_horizontal_rule() { $content = $converter->convert_post( $post_id ); $this->assertStringContainsString( '', $content ); } + + /** + * Test image caption and credit special characters. + */ + public function test_image_caption_and_credit_special_characters() { + $image_id = $this->factory->attachment->create(); + wp_update_post( + [ + 'ID' => $image_id, + 'post_excerpt' => 'Image Caption with á é í ó ú ñ ç ð ð  , &, <, > and •.', + ] + ); + update_post_meta( $image_id, '_media_credit', 'Image Credit with á é í ó ú ñ ç ð ð  , &, <, > and •.' ); + + $post_id = $this->factory->post->create( + [ + 'post_title' => 'Test Post', + 'post_content' => '
Image Caption with á é í ó ú ñ ç ð ð  , &, <, > and •.
', + ] + ); + + $converter = new InDesign_Converter(); + $content = $converter->convert_post( $post_id ); + $this->assertStringContainsString( 'Image Caption with <0x00E1> <0x00E9> <0x00ED> <0x00F3> <0x00FA> <0x00F1> <0x00E7> <0x00F0> <0x00F0> , &, <, > and n.', $content ); + $this->assertStringContainsString( 'Image Credit with <0x00E1> <0x00E9> <0x00ED> <0x00F3> <0x00FA> <0x00F1> <0x00E7> <0x00F0> <0x00F0> , &, <, > and n.', $content ); + } }