Opened 19 years ago
Closed 3 years ago
#3833 closed defect (bug) (worksforme)
Extra </p> inside blockquote
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 2.7 |
| Component: | Formatting | Keywords: | wpautop needs-refresh close |
| Focuses: | Cc: |
Description (last modified by )
When using blockquote </p> is inserted directly in front of </blockquote>, making the code invalid XHTML.
Example:
<blockquote>This is a blockquote</blockquote>
Gives the following result:
<blockquote>This is a blockquote</p></blockquote>
Seems like βthis forum thread adresses the same issue in the support forum.
Attachments (6)
Change History (45)
#2
@
19 years ago
- Milestone 2.2 deleted
- Resolution set to worksforme
- Status changed from new to closed
#3
@
18 years ago
- Resolution worksforme deleted
- Status changed from closed to reopened
- Version changed from 2.1 to 2.3.1
On version 2.3.1 this is still an issue.
For example, a post with only <blockquote>some quote</blockquote> will result in <blockquote>some quote</p></blockquote>, which is invalid XHTML.
This seems to me to be a result of:
- formatting.php:78 $pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee);
- not having/not adding an opening "<p>" tag at the beginning of the post (even though it does get added for other all-text entries)
#4
@
18 years ago
- Description modified (diff)
- Keywords wpautop autop added
- Priority changed from low to normal
ENV: WP trunk r6301
Confirmed bug exists as described.
The bug won't reproduce if there are no blank lines before the blockquotes, or if there is a paragraph before the blockquote. That likely explains it working for rob1n .
Repro having a block quote by the only text, inserted using visual editor.
Removed that part about blockquote in a list from description.
#6
@
17 years ago
- Cc Archibald Leaurees added
- Component changed from Administration to Validation
- Owner changed from anonymous to Archibald Leaurees
- Status changed from reopened to new
- Version changed from 2.3.1 to 2.7
This bug is still there.
When wpautop deals with that content :
text before
<div class="whatever">
<blockquote>
text inside the blockquote tag
</blockquote>
Some text inside the div embedding the blockquote and after the closing blockquote tag
</div>
wpautop returns the following output :
<p> text before</p>
<div class="whatever">
<blockquote><p>
text inside the blockquote tag
</p></blockquote>
<p> Some text inside the div embedding the blockquote and after the closing blockquote tag
</p></div>
Everything is ok. The output of wpautop is just like we want it to be.
But when we try the following input :
text before <div class="whatever">
<blockquote>
text inside the blockquote tag
</blockquote>
Some text inside the div embedding the blockquote and after the closing blockquote tag
</div>
wpautop returns :
<p> text before
<div class="whatever">
<blockquote><p>
text inside the blockquote tag
</p></blockquote>
<p> Some text inside the div embedding the blockquote and after the closing blockquote tag
</p></div>
Obviously that's not a valid HTML. There's an openning 'p' tag just at the beginning, which one won't be closed.
We can reproduce that bug also using the following HTML code sample :
text before <div class="whatever"><blockquote>
text inside the blockquote tag
</blockquote>
Some text inside the div embedding the blockquote and after the closing blockquote tag
</div>
After passing that content to wpautop, we have, as output, the following content :
<p> text before
<div class="whatever">
<blockquote>
text inside the blockquote tag
</p></blockquote>
<p> Some text inside the div embedding the blockquote and after the closing blockquote tag
</p></div>
As you can see there's some orphan tags. The openning p-tag before the beginning text and a closing p-tag just before the closing blockquote-tag.
There's other examples. But the two given are clear enough.
I've spent some hours looking for a solution or a patch. Helping is better that complaining. I've extracted the function, put it in a separated file and give it the real output of 'get_shortcode_regex()', because wpautopo uses it. you can have a look on the page I used here βhttp://www.flegme.fr/wpautopdebug.php. And here's the same page with my bug fix applied βhttp://www.flegme.fr/wpautopdebugafter.php (the php deugging file is attached as wpautopdebug.php)
So the solution is rather simple. In the wpautop php code at line 37,38 you've got :
$pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee);
$pee = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $pee);
I've noticed that those two lines add newlines '\n' before and after some special tags (including the 'div' tag and the 'blockquote' tag). But the first regular expression adds one '\n' only where the second one adds two ones.
When I modify the code that it inserts two newlines before and after the special tags, the bug disapears.
So those two lines become :
$pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n\n$1", $pee);
$pee = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $pee);
Maybe i've missed something and my solution is not the good one... But that worked fine for me.
Regards
Archibald Leaurees
#9
@
17 years ago
in 11256:
<blockquote>some quote</blockquote>
works fine
text before
<div class="whatever">
<blockquote>
text inside the blockquote tag
</blockquote>
Some text inside the div embedding the blockquote and after the closing blockquote tag
</div>
clunky but works too
text before <div class="whatever">
<blockquote>
text inside the blockquote tag
</blockquote>
Some text inside the div embedding the blockquote and after the closing blockquote tag
</div>
fails
text before <div class="whatever"><blockquote>
text inside the blockquote tag
</blockquote>
Some text inside the div embedding the blockquote and after the closing blockquote tag
</div>
fails
and the patch fixes everything indeed.
#10
@
17 years ago
- Keywords has-patch tested commit added; blockquote invalid list paragraph tags wpautop autop removed
- Milestone changed from 2.9 to 2.8
#11
@
17 years ago
just closed #6401 as dup. second patch fixes this:
<dd>paragraph 1 paragraph 2 paragraph 3</dd>
Using <blockquote> inside <li> is invalid. Use <q> instead.
For me, <blockquote>Hello, world. Wonder what this will do.</blockquote> puts <p>...</p> inside the <blockquote> fine.
This is with r5142. Closing as worksforme.