Page MenuHomePhabricator

randomimage does not output the same characters it reads
Closed, ResolvedPublicBUG REPORT

Description

Steps to Reproduce:

  1. Open a wiki.
  2. Search wikimedia file page with image caption. For example: https://tuscriaturas.miraheze.org/wiki/Archivo:Lurming_2.png
  3. Put the name of target file inside randomimage code. Example:
<randomimage float="center" choices="Lurming_2.png" />
  1. Watch results.

Actual Results:
The image shows as expected, but the text is not shown properly.

  • Nuestros misiles encandilarán el Sol...

á is wrong encoding.

Expected Results:
Current image caption for this image is

"- Nuestros misiles encandilarán el Sol... - ¡Entonces lucharemos al mediodía!"

  1. Encandilarán with á in it.
  2. Is expected that full caption is displayed.

Event Timeline

Restricted Application added subscribers: RhinosF1, Reception123. · View Herald Transcript

In Extension Talk, RandomImage/Archive. In this section:
https://www.mediawiki.org/wiki/Extension_talk:RandomImage/Archive#For_russian_encoding

Someone provides code for solving the encoding in languages with special characters like russian, german, chinese, etc:

public function render() {
		$title = $this->pickImage();
		if( $title instanceof Title && $this->imageExists( $title ) ) {
			return //$this->removeMagnifier( 
				$this->parser->recursiveTagParse(
					base64_decode ($this->buildMarkup( $title ))
				//)
			);
		}
		return '';
	}

	protected function buildMarkup ( $title ) {
		$parts[] = $title->getPrefixedText();
		$parts[] = 'thumb';
		if( $this->width !== false )
			$parts[] = "{$this->width}px";
		if( $this->float )
			$parts[] = $this->float;
		$parts[] = $this->getCaption( $title );
		return ( base64_encode ('[[' . implode( '|', $parts ) . ']]'));
	}

Several people say in the talk page that this code fix their encoding locally. But it seems that after all this years, the encoding in the original source is still incomplete.
How can we solve the encoding of Extension:Randomimage?
If I can help in any way, tell me or send me a message.

Change 640072 had a related patch set uploaded (by Jack Phoenix; owner: Jack Phoenix):
[mediawiki/extensions/RandomImage@master] Ensure that we output valid UTF-8 instead of mojibake

https://gerrit.wikimedia.org/r/640072

Change 640072 merged by jenkins-bot:
[mediawiki/extensions/RandomImage@master] Ensure that we output valid UTF-8 instead of mojibake

https://gerrit.wikimedia.org/r/640072

ashley claimed this task.
ashley removed a project: Patch-For-Review.

Change 655391 had a related patch set uploaded (by RhinosF1; owner: Jack Phoenix):
[mediawiki/extensions/RandomImage@REL1_35] Ensure that we output valid UTF-8 instead of mojibake

https://gerrit.wikimedia.org/r/655391

Change 655391 merged by jenkins-bot:
[mediawiki/extensions/RandomImage@REL1_35] Ensure that we output valid UTF-8 instead of mojibake

https://gerrit.wikimedia.org/r/655391