Repository navigation
fix: escape pipes in the moinmoin and textile formats - #502
Open
rahul05ranjan wants to merge 1 commit into
Open
rahul05ranjan wants to merge 1 commit into
rahul05ranjan wants to merge 1 commit into
Conversation
A literal | in a cell or header silently split it into extra columns: || is the cell separator in MoinMoin tables and | in Textile, so 'a || b' became three cells and the second one's style attribute landed on a phantom cell. Write literal pipes as &astanin#124; in the values of both formats, like the mediawiki fix and the escape_map machinery the github/pipe formats use for their separator. Fixes astanin#501 Co-authored-by: rahul05ranjan <11793455+rahul05ranjan@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
tablefmt="moinmoin"andtablefmt="textile"write cell and header values raw, so a literal pipe in the content silently splits the cell — the same class as the mediawiki problem (#499), with these two formats' own separators:||is the cell separator in MoinMoin tables, soa || bbecomes three cells and the style attribute lands on a phantom cell. In textile,|is the separator, sox | ysplits in two. Rendered on a real MoinMoin wiki or through a textile converter, the data is silently corrupted.Fixes #501
Fix
Write literal pipes as
|in the values of both formats — MoinMoin and Textile both pass numeric character references through and render them as the literal character:_moin_row_with_attrsescapes cell values (header cells included, they go through the same function)._textile_row_with_attrsescapes data-row values, and the textile header row now uses the existingDataRow.escape_mapmachinery ({r"|": r"|"}) — the same mechanismGITHUB_ESCAPE_RULESuses for thepipe/githubformats.Values without pipes are byte-identical to before; the existing
test_moinmoin*pins are unchanged.Verification
Two new tests (
test_moinmoin_escapes_pipes,test_textile_escapes_pipes) fail onmasterand pass with this change. Full suite:python3 -m pytest test/→ 351 passed, 17 skipped, zero failures.