Ticket #2069 (closed Bug: fixed)

Opened 2 months ago

Last modified 3 weeks ago

Table issue with template and heading

Reported by: 360R8 Assigned to:
Priority: Normal Milestone:
Component: Project : MediaWiki+FCKeditor Version: FCKeditor 2.5.1
Keywords: Confirmed HasPatch Cc:

Description

If I have a table like this {| {{table}}

! A B |- ! 1 | 2 |} After using the editor it gets munged like this {| |- | A | B |- | 1 | 2 |} Table template removed, and headings changed from ! to |. Any workarounds for this ?

Attachments

2069.patch (3.1 kB) - added by wwalc on 04/18/08 12:18:37.

Change History

03/28/08 23:27:21 changed by wwalc

  • keywords changed from table template headings to WorksForMe Pending.

Check the latest version of MediaWiki extension. Problem with table headers has been fixed today (#2044).

I believe that {{table}} can't appear after {|. I tried to add the following text

{| {{table}}
 ! A || B
 |-
 ! 1
 | 2
 |}

in MediaWiki Sandbox and the table template has been stripped as well, so the behaviour seems to be correct.

03/31/08 17:48:51 changed by 360R8

Hello,

thank you for the quick fix on table headers.

For embeding template in table syntax, please take a look at this wiki source http://www.mediawiki.org/wiki/Template:Tableheader

I also tried the following on the sandbox(http://www.mediawiki.org/wiki/Sandbox), and the template is applied properly

{| {{Tableheader}} ! A ! B |- |1 |2 |}

Thanks.

04/02/08 08:32:32 changed by wwalc

  • keywords changed from WorksForMe Pending to Confirmed.

04/18/08 12:18:37 changed by wwalc

  • attachment 2069.patch added.

04/18/08 12:28:02 changed by wwalc

  • keywords changed from Confirmed to Confirmed HasPatch.

I'm attaching a patch. It relies on a hook that doesn't exist yet. With this patch, if template is inside of a tag, it is not surrounded by a <span> tag. It is also required to tell Sanitizer to not remove our special word that is replaced with the template content at the end of processing, that's why new hook is necessary.

In includes/Sanitizer.php, function fixTagAttributes, add this before the last line (with return statement):

if ( !wfRunHooks( 'SanitizerAfterFixTagAttributes', array( $text, $element, &$attribs ) ) ) {
	return '';
}

it should look similar to:

static function fixTagAttributes( $text, $element ) {
	if( trim( $text ) == '' ) {
		return '';
	}

	$stripped = Sanitizer::validateTagAttributes(
		Sanitizer::decodeTagAttributes( $text ), $element );

	$attribs = array();
	foreach( $stripped as $attribute => $value ) {
		$encAttribute = htmlspecialchars( $attribute );
		$encValue = Sanitizer::safeEncodeAttribute( $value );

		$attribs[] = "$encAttribute=\"$encValue\"";
	}
	if ( !wfRunHooks( 'SanitizerAfterFixTagAttributes', array( $text, $element, &$attribs ) ) ) {
		return '';
	}
	return count( $attribs ) ? ' ' . implode( ' ', $attribs ) : '';
}

Let me know if that worked for you.

04/22/08 14:04:26 changed by wwalc

  • status changed from new to closed.
  • resolution set to fixed.

Fixed with [1941].

04/22/08 14:15:09 changed by wwalc

#2147 marked as DUP.

04/22/08 15:09:19 changed by wwalc

Hook added to the core in MediaWiki 1.13 (r33726, r33725): https://bugzilla.wikimedia.org/show_bug.cgi?id=13821.

Users of MW 1.10-1.12 must apply changes in includes/Sanitizer.php manually.