dompdf/php-font-lib

Undefined offset: 1 in Binary stream

mnabialek opened this issue · 2 comments

I'm using DomPDF 0.7 for this and I use code something like this:

        <table>
            <tr class="title">
                <td colspan="2">
                    Some text
                </td>
            </tr>
            <tr class="links">
                <td>
                    <a href="http://xxx"><strong>xxx</strong></a>
                </td>
                <td>
                    <a href="mailto:yyy><strong>yyy</strong></a>
                </td>
            </tr>
        </table>

The problem here is that when I use <strong> inside 3rd <td> I'm getting undefined ofsset 1 in BinaryStream for this loop:

          for ($i = 0; $i < $type[1]; $i++) {
            $ret += $this->w($type[0], $data[$i]);
          }

As soon as I remove <strong> so I have code like this:

<a href="mailto:yyy>yyy</a>

no error appears. Exactly same situation is when I use CSS font-weight: bold instead of <strong> tag.

The solution that seems to be working is replacing the code I showed above into:

for ($i = 0; $i < $type[1]; $i++) {
     if (array_key_exists($i, $data)) {
           $ret += $this->w($type[0], $data[$i]);
     }
}

everything works as expected. If approved I can create pull request for this.

ref #50

PhenX commented

Fixed by 010c3e0