WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 5 years ago

#6607 closed defect (bug) (duplicate)

RSS widget doesn't correct the target encoding

Reported by: guillep2k Owned by: guillep2k
Milestone: Priority: normal
Severity: normal Version: 2.5.1
Component: General Keywords: has-patch tested
Focuses: Cc:

Description

When your blog is iso-8859-1 and your RSS widget takes information from an UTF-8 blog, the characters in your page can become garbled. The reverse is also true (your blog is UTF-8 and the RSS'd blog is ISO-8859-1). Here's my proposal for wp-includes/rss.php (around line 62):

		$this->parser = $parser;

#MODIFICATIONS BEGIN
switch( @strtoupper(get_option('blog_charset')) )
{
	case 'UTF-8':
		xml_parser_set_option( $this->parser, XML_OPTION_TARGET_ENCODING, 'UTF-8' );
		break;
	case 'ISO-8859-1':
		xml_parser_set_option( $this->parser, XML_OPTION_TARGET_ENCODING, 'ISO-8859-1' );
		break;
}
#MODIFICATIONS END
		# pass in parser, and a reference to this object
		# setup handlers
		#
		xml_set_object( $this->parser, $this );
		xml_set_element_handler($this->parser,

This would handle only iso-8859-1 to utf-8 and vice-versa, but most western blogs use one of these two encodings. Handling a percentage of the cases is better than none at all, I think. :)

Attachments (1)

6607.diff (606 bytes) - added by guillep2k 6 years ago.

Download all attachments as: .zip

Change History (6)

guillep2k6 years ago

comment:1 guillep2k6 years ago

  • Keywords has-patch added
  • Milestone changed from 2.7 to 2.5.2
  • Version changed from 2.6 to 2.5.1

Added a patch for the proposed change.

comment:2 guillep2k6 years ago

  • Owner changed from anonymous to guillep2k
  • Status changed from new to assigned

comment:3 guillep2k6 years ago

  • Keywords tested added

I tested the patch with 2.5.1, using a blog set up to ISO-8859-1 and taking an RSS from an UTF-8 blog.

comment:4 ryan6 years ago

  • Milestone changed from 2.5.2 to 2.9

Milestone 2.5.2 deleted

comment:5 ryan5 years ago

  • Milestone 2.9 deleted
  • Resolution set to duplicate
  • Status changed from assigned to closed

See #7563

Note: See TracTickets for help on using tickets.