Opened 8 years ago
Closed 8 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 )
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 , 8 years ago
Description: | modified (diff) |
---|
comment:3 by , 8 years ago
Reproduced on demo-1.0 (1.0.14.dev0): https://trac.edgewall.org/demo-1.0/ticket/5040
comment:4 by , 8 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 , 8 years ago
Milestone: | 1.0.14 → next-stable-1.0.x |
---|
comment:6 by , 8 years ago
Description: | modified (diff) |
---|
comment:8 by , 8 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>
follow-up: 10 comment:9 by , 8 years ago
Milestone: | next-stable-1.0.x → 1.0.14 |
---|---|
Owner: | set to |
Status: | new → assigned |
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>
comment:10 by , 8 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 , 8 years ago
Have you considered something like this?
-
trac/wiki/formatter.py
diff -r 21135f973074 trac/wiki/formatter.py
a b 1319 1319 if not line.startswith(' '): 1320 1320 self._tabstops = [] 1321 1321 1322 # Handle end of indentation 1323 if not line.startswith(' ') and self._quote_stack: 1324 self.close_indentation() 1325 1322 1326 self.in_list_item = False 1323 1327 self.in_quote = False 1324 1328 # Throw a bunch of regexps on the problem
It seems simpler and passing the tests.
comment:12 by , 8 years ago
Thanks for the review! Revised jomae.git@t12675 and verified unit tests passing.
comment:13 by , 8 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 , 8 years ago
Release Notes: | modified (diff) |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Committed in [15687] and merged in [15688-15689].
See also #11009. Need to confirm issue exists also for 1.0-stable.