Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

display: table-cell outside of a table causes a crash #691

Closed
halfer opened this issue Aug 4, 2013 · 4 comments
Closed

display: table-cell outside of a table causes a crash #691

halfer opened this issue Aug 4, 2013 · 4 comments

Comments

@halfer
Copy link

halfer commented Aug 4, 2013

If a class applies a table-cell format outside of a table, a fatal error is thrown:

Fatal error: Call to a member function get_cellmap() on a non-object in .../dompdf/include/table_cell_frame_reflower.cls.php on line 30

Repro document:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>Crash cell test</title>
  <style type="text/css" >
      .about {
          color: grey;
          font-style: italic;
      }
      .highlight {
          background-color: greenyellow;
          display: table-cell;
      }
  </style>
</head>
<body>
    <h1>Crash cell test</h1>

    <p>This bug crashes the DOMPDF renderer.</p>

    <p class="about">The <code>display: table-cell</code> property/value causes a fatal error
        if the affected item is not actually in a table:</p>

    <!-- CRASH HERE -->
    <p>Here is <span class="highlight">a span</span> with no padding.</p>

    <p class="about">A table cell however is fine (change the class of the span above to allow DOMPDF
        to finish):</p>

    <table>
        <tr>
            <td class="highlight">
                Cell
            </td>
        </tr>
    </table>
</body>
</html>

I'm on PHP 5.3.25 on Mac 10.6.8, running DOMPDF 54551d32450.

@bsweeney
Copy link
Member

bsweeney commented Aug 5, 2013

dompdf does not currently support anonymous table objects, though we do plan to support them in a future release (see issue #449). In the meantime you can work around the issue by filling out the necessary table structure. It requires extra markup that you don't need with the web browser, but it does address the issue:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>Crash cell test</title>
  <style type="text/css" >
      .table {
          display: table;
      }
      .tr {
          display: table-row;
      }
      .highlight {
          background-color: greenyellow;
          display: table-cell;
      }
  </style>
</head>
<body>

    <!-- NO MORE CRASH HERE -->
    <p>Here is <span class="table"><span class="tr"><span class="highlight">a span</span></span></span> with no padding.</p>

</body>
</html>

@halfer
Copy link
Author

halfer commented Aug 6, 2013

Ah righto, thanks. I found I didn't need this one in the end, so feel free to close this if it dups the other ticket. Just thought I'd raise it in case it'd not already been found.

@greyskymedia
Copy link

+1 on this fix. thanks!

@hattamuhammadan
Copy link

thank Mister @bsweeney bsweeney

@bsweeney bsweeney closed this as completed Jun 8, 2020
@bsweeney bsweeney removed this from the 1.0.0 milestone Nov 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants