Make WordPress Core

Ticket #21007: 21007.diff

File 21007.diff, 4.9 KB (added by boonebgorges, 7 years ago)
  • new file tests/phpunit/data/export/slashes.xml

    diff --git a/tests/phpunit/data/export/slashes.xml b/tests/phpunit/data/export/slashes.xml
    new file mode 100644
    index 0000000..3e073d8
    - +  
     1<?xml version="1.0" encoding="UTF-8" ?>
     2<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
     3<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
     4<!-- You may use this file to transfer that content from one site to another. -->
     5<!-- This file is not intended to serve as a complete backup of your site. -->
     6
     7<!-- To import this information into a WordPress site follow these steps: -->
     8<!-- 1. Log in to that site as an administrator. -->
     9<!-- 2. Go to Tools: Import in the WordPress admin panel. -->
     10<!-- 3. Install the "WordPress" importer from the list. -->
     11<!-- 4. Activate & Run Importer. -->
     12<!-- 5. Upload this file using the form provided on that page. -->
     13<!-- 6. You will first be asked to map the authors in this export file to users -->
     14<!--    on the site. For each author, you may choose to map to an -->
     15<!--    existing user on the site or to create a new user. -->
     16<!-- 7. WordPress will then import each of the posts, pages, comments, categories, etc. -->
     17<!--    contained in this file into your site. -->
     18
     19<!-- generator="WordPress/3.1-RC2-17315" created="2011-01-18 08:06" -->
     20<rss version="2.0"
     21        xmlns:excerpt="http://wordpress.org/export/1.1/excerpt/"
     22        xmlns:content="http://purl.org/rss/1.0/modules/content/"
     23        xmlns:wfw="http://wellformedweb.org/CommentAPI/"
     24        xmlns:dc="http://purl.org/dc/elements/1.1/"
     25        xmlns:wp="http://wordpress.org/export/1.1/"
     26>
     27
     28<channel>
     29        <title>trunk</title>
     30        <link>http://localhost/</link>
     31        <description>trunk</description>
     32        <pubDate>Tue, 18 Jan 2011 08:06:21 +0000</pubDate>
     33        <language>en</language>
     34        <wp:wxr_version>1.1</wp:wxr_version>
     35        <wp:base_site_url>http://localhost/</wp:base_site_url>
     36        <wp:base_blog_url>http://localhost/</wp:base_blog_url>
     37
     38        <wp:author><wp:author_id>1</wp:author_id><wp:author_login>admin</wp:author_login><wp:author_email>local@host.null</wp:author_email><wp:author_display_name><![CDATA[admin]]></wp:author_display_name><wp:author_first_name><![CDATA[]]></wp:author_first_name><wp:author_last_name><![CDATA[]]></wp:author_last_name></wp:author>
     39
     40        <wp:category><wp:term_id>8</wp:term_id><wp:category_nicename>alpha</wp:category_nicename><wp:category_parent></wp:category_parent><wp:cat_name><![CDATA[a \"great\" category]]></wp:cat_name></wp:category>
     41        <wp:tag><wp:term_id>33</wp:term_id><wp:tag_slug>tag1</wp:tag_slug><wp:tag_name><![CDATA[foo\'bar]]></wp:tag_name></wp:tag>
     42
     43        <generator>http://wordpress.org/?v=3.1-RC2-17315</generator>
     44
     45        <item>
     46                <title>Hello world!</title>
     47                <link>http://localhost/?p=1</link>
     48                <pubDate>Tue, 18 Jan 2011 07:40:14 +0000</pubDate>
     49                <dc:creator>author</dc:creator>
     50                <guid isPermaLink="false">http://localhost/?p=1</guid>
     51                <description></description>
     52                <content:encoded><![CDATA[Slashes aren\'t \"cool\"]]></content:encoded>
     53                <excerpt:encoded><![CDATA[]]></excerpt:encoded>
     54                <wp:post_id>1</wp:post_id>
     55                <wp:post_date>2011-01-18 07:40:14</wp:post_date>
     56                <wp:post_date_gmt>2011-01-18 07:40:14</wp:post_date_gmt>
     57                <wp:comment_status>open</wp:comment_status>
     58                <wp:ping_status>open</wp:ping_status>
     59                <wp:post_name>hello-world</wp:post_name>
     60                <wp:status>publish</wp:status>
     61                <wp:post_parent>0</wp:post_parent>
     62                <wp:menu_order>0</wp:menu_order>
     63                <wp:post_type>post</wp:post_type>
     64                <wp:post_password></wp:post_password>
     65                <wp:is_sticky>0</wp:is_sticky>
     66                <category domain="category" nicename="alpha"><![CDATA[a \"great\" category]]></category>
     67                <wp:postmeta>
     68                        <wp:meta_key>Post by</wp:meta_key>
     69                        <wp:meta_value><![CDATA[admin]]></wp:meta_value>
     70                </wp:postmeta>
     71                <wp:postmeta>
     72                        <wp:meta_key>_edit_last</wp:meta_key>
     73                        <wp:meta_value><![CDATA[1]]></wp:meta_value>
     74                </wp:postmeta>
     75        </item>
     76</channel>
     77</rss>
  • tests/phpunit/tests/import/import.php

    diff --git a/tests/phpunit/tests/import/import.php b/tests/phpunit/tests/import/import.php
    index e253a9b..fa0bcbb 100644
    a b class Tests_Import_Import extends WP_Import_UnitTestCase { 
    249249                $wp_importers = $_wp_importers; // Restore global state
    250250        }
    251251
     252        /**
     253         * @ticket 21007
     254         */
     255        public function test_slashes_should_not_be_stripped() {
     256                global $wpdb;
     257
     258                $authors = array( 'admin' => false );
     259                $this->_import_wp( DIR_TESTDATA . '/export/slashes.xml', $authors );
     260
     261                $alpha = get_term_by( 'slug', 'alpha', 'category' );
     262                $this->assertSame( 'a \"great\" category', $alpha->name );
     263
     264                $tag1 = get_term_by( 'slug', 'tag1', 'post_tag' );
     265                $this->assertSame( "foo\'bar", $tag1->name );
     266
     267                $posts = get_posts( array( 'post_type' => 'any', 'post_status' => 'any' ) );
     268                $this->assertSame( 'Slashes aren\\\'t \"cool\"', $posts[0]->post_content );
     269        }
     270
    252271        // function test_menu_import
    253272}