Edgewall Software
Modify

Opened 4 years ago

Closed 4 years ago

#12675 closed defect (fixed)

WikiFormatting leaking to HTML

Reported by: anonymous Owned by: Jun Omae
Priority: normal Milestone: 1.0.14
Component: wiki system Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:

Fix inline markups leaking after indent.

API Changes:
Internal Changes:

Description (last modified by Jun Omae)

When a user writes a wrong WikiFormatting syntax inside a textarea that accepts the WikiFormatting, the formatting rule "leaks" to the subsequent HTML and the ticket cannot be updated. A message that the ticket was modified by another user is displayed.

Example: demo-1.0:#5040

54******94
Vl

       C
54******94

Attachments (0)

Change History (14)

comment:1 by anonymous, 4 years ago

Description: modified (diff)

comment:2 by Ryan J Ollos, 4 years ago

Milestone: 1.0.14

See also #11009. Need to confirm issue exists also for 1.0.14.

Version 0, edited 4 years ago by Ryan J Ollos (next)

comment:3 by anonymous, 4 years ago

Reproduced on demo-1.0 (1.0.14.dev0): https://trac.edgewall.org/demo-1.0/ticket/5040

comment:4 by Christian Boos, 4 years ago

There might be a quick fix on the current code base, if anyone wants to tackle it, feel free.

Otherwise, I'll try to fix it by reworking the HTML generation in the wiki Formatter, just got an idea this morning ;-)

comment:5 by Ryan J Ollos, 4 years ago

Milestone: 1.0.14next-stable-1.0.x

comment:6 by Jun Omae, 4 years ago

Description: modified (diff)

comment:7 by anonymous, 4 years ago

Any updates?

comment:8 by Jun Omae, 4 years ago

Inline markup after indent line leads this issue:

>>> import trac
>>> trac.__version__
'1.0.13'
>>> from trac.mimeview.api import RenderingContext
>>> from trac.resource import Resource
>>> from trac.test import EnvironmentStub
>>> from trac.test import MockRequest
>>> from trac.wiki.formatter import Formatter, format_to_html
>>> resource = Resource('wiki', 'WikiStart')
>>> env = EnvironmentStub()
>>> req = MockRequest(env)
>>> context = RenderingContext(resource, req.href, req.perm)
>>> context.req = req
>>> print(format_to_html(env, context, """\
... 54******94
... Vl
...
...        C
... 54******94
... """))
<p>
54<strong></strong><strong>94
Vl
</strong></p>
<blockquote>
<p>
C
</strong></p>
</blockquote>
<p>
54<strong></strong><strong>94
</p>

>>> print(format_to_html(env, context, """\
...   indent
... **
... """))
<blockquote>
<p>
indent
</strong></p>            # <== unbalanced </strong>
</blockquote>
<p>
<strong>                 # <== missing </strong>
</p>

comment:9 by Jun Omae, 4 years ago

Milestone: next-stable-1.0.x1.0.14
Owner: set to Jun Omae
Status: newassigned

Proposed changes in [eb347148a/jomae.git] (jomae.git@t12675). Also, I noticed similar issue #11009.

After the changes:

>>> print(format_to_html(env, context, """\
... 54******94
... Vl
...
...        C
... 54******94
... """))
<p>
54<strong></strong><strong>94
Vl
</strong></p>
<blockquote>
<p>
C
</p>
</blockquote>
<p>
54<strong></strong><strong>94
</strong></p>

>>> print(format_to_html(env, context, """\
...   indent
... **
... """))
<blockquote>
<p>
indent
</p>
</blockquote>
<p>
<strong>
</strong></p>

in reply to:  9 comment:10 by Jun Omae, 4 years ago

Replying to Jun Omae:

Proposed changes in [eb347148a/jomae.git] (jomae.git@t12675). Also, I noticed similar issue #11009.

Could someone please review the changes?

p.s. I've attempted to move fix for #11009 to _format_line added in [eb347148a/jomae.git] but that's unsuccessful.

comment:11 by Peter Suter, 4 years ago

Have you considered something like this?

  • trac/wiki/formatter.py

    diff -r 21135f973074 trac/wiki/formatter.py
    a b  
    13191319            if not line.startswith(' '):
    13201320                self._tabstops = []
    13211321
     1322            # Handle end of indentation
     1323            if not line.startswith(' ') and self._quote_stack:
     1324                self.close_indentation()
     1325
    13221326            self.in_list_item = False
    13231327            self.in_quote = False
    13241328            # Throw a bunch of regexps on the problem

It seems simpler and passing the tests.

comment:12 by Jun Omae, 4 years ago

Thanks for the review! Revised jomae.git@t12675 and verified unit tests passing.

comment:13 by wbruna, 4 years ago

On our install (Trac 1.0.1, Debian Wheezy package), [eb347148a/jomae.git] together with the patch from #11009 seems to fix this issue.

comment:14 by Jun Omae, 4 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Committed in [15687] and merged in [15688-15689].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.