Skip to content

Commit

Permalink
Fix an error with Remarkup when a header-indicator row has more cells…
Browse files Browse the repository at this point in the history
… than the one above it

Summary:
From fishing through error logs in PHI184. When row 1 has less cells than row 2, and row 2 has a `|--|` section (indicating that the cell above should be a table header), we try to convert an invalid cell into a table header. PHP obliges and creates this cell, but it doesn't have 'content', which produces this error:

> ERROR 8: Undefined index: content at [/core/lib/libphutil/src/markup/engine/remarkup/blockrule/PhutilRemarkupBlockRule.php:160]

Test Plan: Added a failing (well, complaining) test; made it pass.

Reviewers: amckinley

Reviewed By: amckinley

Differential Revision: https://secure.phabricator.com/D18751
  • Loading branch information
epriestley committed Oct 31, 2017
1 parent 95c0659 commit 353a376
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
@@ -0,0 +1,8 @@
|x|
||--
~~~~~~~~~~
<div class="remarkup-table-wrap"><table class="remarkup-table">
<tr><td>x</td></tr>
</table></div>
~~~~~~~~~~
| x |
Expand Up @@ -73,7 +73,14 @@ public function markupText($text, $children) {
// Mark previous row with headings.
foreach ($cells as $i => $cell) {
if ($cell['content']) {
$rows[last_key($rows)]['content'][$i]['type'] = 'th';
$last_key = last_key($rows);
if (!isset($rows[$last_key]['content'][$i])) {
// If this row has more cells than the previous row, there may
// not be a cell above this one to turn into a <th />.
continue;
}

$rows[$last_key]['content'][$i]['type'] = 'th';
}
}
}
Expand Down

0 comments on commit 353a376

Please sign in to comment.