Edgewall Software
Modify

Opened 20 months ago

Closed 20 months ago

Last modified 14 months ago

#13589 closed defect (invalid)

`#!html` processor incorrectly closes at end of wiki text, not `}}}`

Reported by: anonymous Owned by:
Priority: normal Milestone:
Component: wiki system Version: 1.4.3
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description (last modified by geert.linders@…)

If I set the style in a {{{#!html ... }}} section, this leaks into the rest of the wicket or wiki page:

The text I used is:

= HTML Leak
{{{#!html
<div  style="background-color:lightgrey;">
<h4>Header</h4>
<p>Some text...</p>
}}}
Background leaks here...
= Next section
Background leaks here too...

I would expect all HTML settings and other features that I use or changes that I make inside a {{{ ... }}} block, that they are limited to this block.

Attachments (2)

html_leak.png (13.2 KB ) - added by geert.linders@… 20 months ago.
t13589-bad-wiki.png (20.0 KB ) - added by Jun Omae 20 months ago.

Download all attachments as: .zip

Change History (10)

by geert.linders@…, 20 months ago

Attachment: html_leak.png added

comment:1 by geert.linders@…, 20 months ago

Oops! Forgot to add my email address.

comment:2 by geert.linders@…, 20 months ago

Description: modified (diff)

comment:3 by Jun Omae, 20 months ago

Component: generalwiki system
Milestone: 1.4.4
Summary: {{{#!html style leaks into ticket and wiki`#!html` processor incorrectly closes at end of wiki text, not `}}}`
Version: 1.4.3

Thanks for the reporting.

Another example

= Header 1
Pre text.
{{{#!html
<div style="border:2px solid orange;padding:1em">
<h4>Header 4</h4>
<p>Some text...</p>
}}}
Post text.

= Header 2
Pre text.
{{{#!html
<div style="border:2px solid blue;padding:1em">
<h4>Header 4</h4>
<p>Some text...</p>
}}}
Post text.

Result:

by Jun Omae, 20 months ago

Attachment: t13589-bad-wiki.png added

comment:4 by Jun Omae, 20 months ago

Milestone: 1.4.4
Resolution: invalid
Status: newclosed

Ah. That is caused by missing </div> in the #!html processor.

{{{#!html
<div  style="background-color:lightgrey;">
<h4>Header</h4>
<p>Some text...</p>
</div>        <!--  MISSING -->
}}}

comment:5 by geert.linders@…, 20 months ago

I know the </div> is missing. But that is not the issue here.

Anything you do inside {{{ ... }}} should not affect the rest of the ticket or wiki page.

The closing }}} should restore the style sheet of the ticket or wiki page.

in reply to:  5 comment:6 by Jun Omae, 20 months ago

Milestone: next-stable-1.4.x

Replying to geert.linders@…:

I know the </div> is missing. But that is not the issue here.

Anything you do inside {{{ ... }}} should not affect the rest of the ticket or wiki page.

The closing }}} should restore the style sheet of the ticket or wiki page.

You know? You didn't explain that. Well, add </div> as a workaround.

Hm. Document for #!html processor says in WikiHtml:

The filtering is done by ​Genshi and the output will be a well-formed fragment of HTML. This means that you cannot use two HTML blocks, one for opening a <div> and another for closing it, in order to wrap arbitrary wiki text.

Currently, the output of #!html processor with unbalanced tags is not a well-formed fragment.

>>> from trac.test import EnvironmentStub, MockRequest
>>> from trac.wiki.formatter import format_to_html
>>> from trac.web.chrome import web_context
>>> env = EnvironmentStub()
>>> req = MockRequest(env)
>>> context = web_context(req)
>>> text = """\
... aaa
... {{{#!html
... <div>
... text
... }}}
... bbb
... """
>>> print(format_to_html(env, context, text))
<p>
aaa
</p>
<div>
text
<p>       # <== </div> should be automatically added before <p>
bbb
</p>

comment:7 by geert.linders@…, 20 months ago

Sorry I didn't mention the unbalanced <div> tag.

So it seems we do have an issue. Although probably a minor one because there is a simple workaround.

comment:8 by Ryan J Ollos, 14 months ago

Milestone: next-stable-1.4.x

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The ticket will remain with no owner.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from (none) 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.