Ticket #2157 (new Bug)

Opened 4 months ago

Last modified 2 months ago

editor strips off image comments containing wikitext

Reported by: feystorm Owned by:
Priority: Normal Milestone:
Component: Project : MediaWiki+FCKeditor Version: FCKeditor 2.5.1
Keywords: Confirmed Cc:

Description

If an image's comment contains wikitext, the comment gets stripped off completely when loaded into the editor.

Steps to reproduce: In 'wikitext' editing mode, create an image, and in its comment, put some wikitext such as a media link (example: [[Image:samplefile.png|thumb|right|300px|some caption [[Media:somefile.pdf|PDF version]]]]), and then save or preview the page (if saving, go back to edit again). When the page is re-loaded into the editor, the caption is completely blank.

On line 202 of FCKeditorSkin.body.php, if

if (isset($fp['alt']) && !empty($fp['alt']) && false !== strpos(FCKeditorParser::$fkc_mw_makeImage_options, $fp['alt']) && $fp['alt'] != "Image:" . $orginal) {

is changed to

if (isset($fp['alt'])) {

, the caption will load, but with the wikitext stripped. So in the above case, the comment would become ("some captionPDF version"). This is better than no caption at all, but still not desired behavior.

Until the interface can be modified to allow WYSIWYG caption editing, it should put the raw wikitext into the caption.

I am using FCKeditor 2.5.1 with MediaWiki 1.12.0

Change History

Changed 4 months ago by w.olchawa

  • keywords Confirmed added

Confirmed using MediaWiki 1.12 and the latest FCKeditor SVN release.

Changed 3 months ago by w.olchawa

#2230 has been marked as DUP

Changed 2 months ago by wwalc

Tempoary fix: [2089].

It seems that it can't be fixed without overwriting replaceInternalLinks function from the old Parser. There is no other way to affect this code:

if ( $ns == NS_IMAGE ) {
	wfProfileIn( "$fname-image" );
	if ( !wfIsBadImage( $nt->getDBkey(), $this->mTitle ) ) {
		# recursively parse links inside the image caption
		# actually, this will parse them in any other parameters, too,
		# but it might be hard to fix that, and it doesn't matter ATM
		$text = $this->replaceExternalLinks($text);
		$text = $this->replaceInternalLinks($text);

		# cloak any absolute URLs inside the image markup, so replaceExternalLinks() won't touch them
		$s .= $prefix . $this->armorLinks( $this->makeImage( $nt, $text ) ) . $trail;
		$this->mOutput->addImage( $nt->getDBkey() );

		wfProfileOut( "$fname-image" );
		continue;
	} else {
		# We still need to record the image's presence on the page
		$this->mOutput->addImage( $nt->getDBkey() );
	}
	wfProfileOut( "$fname-image" );
}

this is the line which should be changed before going further...

$this->replaceInternalLinks($text);

it doesn't look like an easy task though.

Note: See TracTickets for help on using tickets.