Wrong output html if table's caption contains headers
Open
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 3.4k
- Forks
- 361
- Avg merge
- 3d 41m
- Merged PRs (30d)
- 2
Description
Hello, on this example HTMLPurifier 4.9.2 returns bad output html:
$text = '<table border="1" style="width:300px">
<caption>
<h2><strong>caption</strong></h2>
</caption>
<tbody>
<tr>
<td style="width:64px;text-align:right"><strong>Life:</strong></td>
<td style="width:80px"><strong>063-560-10-10</strong></td>
</tr>
<tr>
<td style="width:64px;text-align:right"><strong>Skype:</strong></td>
<td style="width:80px"><strong>saleusa</strong></td>
</tr>
<tr>
<td style="width:64px;text-align:right"><strong>Viber:</strong></td>
<td style="width:80px"><strong>0973151111</strong></td>
</tr>
<tr>
<td style="width:64px;text-align:right"><strong>e-mail:</strong></td>
<td style="width:80px"><strong>info@saleusa.com</strong></td>
</tr>
</tbody>
</table>
';
$config = HTMLPurifier_Config::createDefault();
$p = new HTMLPurifier($config);
$html = $p->purify($text);
Output html is:
<h2><strong>caption</strong></h2>
<strong>Life:</strong>
<strong>063-560-10-10</strong>
<strong>Skype:</strong>
<strong>saleusa</strong>
<strong>Viber:</strong>
<strong>0973151111</strong>
<strong>e-mail:</strong>
<strong>info@saleusa.com</strong>
But if I remove h2 tag (change caption to <strong>caption</strong>) everything OK.
Is this a bug or may be I just not turn on some settings?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with HTMLPurifier_Config::createDefault() and HTMLPurifier::purify(), using the supplied table and caption markup as the reproduction. Compare the output when the caption contains an
with the output when it contains only , then add a regression check for the expected table structure. Done means the table and caption are preserved correctly in both cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100