Last modified: 2006-12-17 22:16:32 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T10293, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 8293 - Use of center tag ruins paragraph formatting
Use of center tag ruins paragraph formatting
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Parser (Other open bugs)
1.9.x
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
http://it.wikipedia.org/wiki/Utente:A...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2006-12-17 15:26 UTC by Alfio Puglisi
Modified: 2006-12-17 22:16 UTC (History)
0 users

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Patch to doBlockLevels() Parser.php (1.06 KB, patch)
2006-12-17 16:34 UTC, Ilmari Karonen
Details

Description Alfio Puglisi 2006-12-17 15:26:14 UTC
When using a center html tag, the following two paragraphs are not broken up,
but instead appear joined. Example test:
--- start wikitext --
<center>
foo
</center>
  
bar

foo
--- end wikitext --

after the first centered "foo", the page reads "bar foo" on a single line. See
the provided URL for an example.
Comment 1 Ilmari Karonen 2006-12-17 15:54:28 UTC
I've no idea what's causing this, but I've added a parser test for it in r18402.
Comment 2 Ilmari Karonen 2006-12-17 16:16:49 UTC
Note, this does not happen if the center tags are replaced with div, nor if the
opening and closing tag are on the same line.  I suspects some confusion in
doBlockLevels(), but I'm finding it hard to make sense of that code.
Comment 3 Ilmari Karonen 2006-12-17 16:34:38 UTC
Created attachment 2892 [details]
Patch to doBlockLevels() Parser.php

The attached patch, which simply moves "</center" from $openmatch to
$closematch, to match the way "</div" is treated, seems to fix the bug and
causes no other parsertests to regress.  However, I'd rather like to understand
_why_ this is so.
Comment 4 Ilmari Karonen 2006-12-17 16:52:26 UTC
Applied in r18403.
Comment 5 Aryeh Gregor (not reading bugmail, please e-mail directly) 2006-12-17 19:10:15 UTC
Are you sure that doesn't break XHTML validity when you mix it with other stuff?
 See bug 6200, which notes identical behavior for <blockquote> and <li>.  I
tried a similar tweak for that and it resulted in invalid nesting.
Comment 6 Ilmari Karonen 2006-12-17 20:18:30 UTC
I'm not sure if it's possible to fix this properly without rewriting the
relevant loop entirely.  There's a comment in the code that seems to suggest it
was never properly implemented in the first place.  In any case, both <li> and
<blockquote>, like <center>, most certainly should be able to contain <p> tags.
Comment 7 Aryeh Gregor (not reading bugmail, please e-mail directly) 2006-12-17 20:56:43 UTC
Yes, but did the patch you just committed cause the output pages to become
invalid XHTML?  http://validator.w3.org/
Comment 8 Ilmari Karonen 2006-12-17 21:33:27 UTC
It didn't break any existing parser tests, so if there's any breakage it must be
for some case that no-one has thought of testing (which in itself wouldn't be
surprising).  In any case, I frankly consider a possibility of improper nesting
in some yet unknown case to be preferable to the parser just throwing in the
towel on a known input.  (Which, by the way, I coincidentally just found a live
example of at [[Cellular automaton]] -- I worked around it there by switching to
<div align="center">.)
Comment 9 Aryeh Gregor (not reading bugmail, please e-mail directly) 2006-12-17 22:16:32 UTC
First of all, your patch doesn't seem to change the behavior for me.  Paragraphs
in <center> still get eaten.

Second of all, it's a really bad idea to commit patches to code that you by your
own admission don't understand on the basis that they seem to fix the problem
and don't break parser tests.  You run a high risk of screwing things up.

Finally, XHTML validity is not tested for by parser tests, but is nevertheless
important in part (such as validity of nesting), because clients and Tidy may
screw up appearance even more in trying to parse the broken tags.  (Other
aspects, like multiple id's, aren't quite so important.)  I strongly recommend
that you test for XHTML validity, which I would except that your patch doesn't
work for me (see point 1), and revert if you've broken it.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links