Page MenuHomePhabricator

Wishlist intake doesn't properly escape table syntax in the description field
Closed, ResolvedPublicBUG REPORT

Description

What is the problem?

Tables currently can't be used in the "Describe your wish" section because the pipes are reserved characters.

Steps to reproduce problem
  1. Go to create or edit a wish
  2. The following table syntax is an example, but you can also use Insert > Table from the editing toolbar:
{| class="wikitable"
|+ Caption
|-
! Heading 1
|-
| Foo
|}
  1. Save the wish

Expected behavior:

The table appears as it should after saving -- i.e. if I used VisualEditor, it should look the same as it did when I added it in VE.

Observed behavior:

Template call is broken and the table doesn't appear, and other visual errors may also occur.

Details

Other Assignee
dom_walden
TitleReferenceAuthorSource BranchDest Branch
DescritionField: further improve pipe escape algorithmrepos/commtech/wishlist-intake!170musikanimalpipes-in-tablesmain
DescriptionField: improve algorithm for escaping pipes in tablesrepos/commtech/wishlist-intake!139musikanimalpipes-in-tablesmain
DescriptionField: escape pipes in table syntaxrepos/commtech/wishlist-intake!101musikanimalescape-pipes-in-tablesmain
Customize query in GitLab

Event Timeline

@MusikAnimal I don't know if we should escape all pipes. For example, trying to use templates inside a table: https://wishlist-test.toolforge.org/wiki/Community_Wishlist/Wishes/Table_test_B

I copied the wikitext from https://www.mediawiki.org/w/index.php?title=Help:Tables/en&action=edit and put it in a wish. I found a number of examples of pipes which were escaped when they should not have been, or were not escaped when they should be.

  • We might need to escape pipes when they appear inside <code> (and possible <math>) tags (example)
    • Indeed, probably anywhere | appears, except for those noted in the next bullet
  • We might not need to escape pipes inside <nowiki> or <pre> tags (example)
    • At least, when they appear inside tables
  • I am finding circumstances where pipes in tables are not escaped. I am not sure why (example, example)

I copied the wikitext from https://www.mediawiki.org/w/index.php?title=Help:Tables/en&action=edit and put it in a wish. I found a number of examples of pipes which were escaped when they should not have been, or were not escaped when they should be.

I should have mentioned that this isn't going to be perfect, nor is it expected to be. It would take a full-blown parser to get anywhere near perfect, which now that I think of it, MediaWiki should provide a means to do this escaping given it's the only parser capable of doing it perfectly! But I digress..

Anyway, I took the code from Extension:VEForAll so it should be somewhat battle-tested.

  • We might need to escape pipes when they appear inside <code> (and possible <math>) tags (example)
    • Indeed, probably anywhere | appears, except for those noted in the next bullet

Pipes within template calls (i.e. {{foo|bar=baz}} can't be escaped, and those are going to be much more common than tables and whatever else. I'm guessing that's why VEForAll's implementation carefully only escapes table syntax and nothing else; It's likely safer to selectively escape than to escape everything and selectively unescape.

  • We might not need to escape pipes inside <nowiki> or <pre> tags (example)
    • At least, when they appear inside tables

This I took a stab at this. Inline <nowiki> and <pre> should no longer contain escaped pipes. I don't think it's worth trying to make it support multi-line.

  • I am finding circumstances where pipes in tables are not escaped. I am not sure why (example, example)

I think I may have fixed this. The row like | style="padding:5px" should at least be escaped now.

@dom_walden see my comment above at T368458#9952506. Hopefully what we have now is good "enough".

@dom_walden see my comment above at T368458#9952506. Hopefully what we have now is good "enough".

@MusikAnimal Thanks. I noticed that wikitext like:

{| style="width:100%"
! style="width: 50%;"|You type
! style="width: 50%;"|You get
|-
| style="padding: 5px;"| foobar
| style="padding: 5px;"| foobaz
|}

gets transformed to:

{{{!}} class="wikitable"
{{!}}+
! style="width: 50%;"|You type
! style="width: 50%;"|You get
{{!}}-
{{!}} style="padding: 5px;"{{!}} foo
{{!}} style="padding: 5px;"{{!}} bar
{{!}}}

(example)

The pipes in the headers seem to cause problems. Should this be fixed, as it does seem like a fairly basic thing a proposer might want to do?

!170 should fix the issue mentioned at T368458#9965216

Thanks. I can confirm. I will move this along.