dompdf / php-font-lib

A library to read, parse, export and make subsets of different types of font files.
GNU Lesser General Public License v2.1
1.73k stars 256 forks source link

Undefined offset: 1 in Binary stream #52

Closed mnabialek closed 7 years ago

mnabialek commented 7 years ago

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.

bsweeney commented 7 years ago

ref #50

PhenX commented 7 years ago

Fixed by 010c3e0e22a9ab0d9f93678692c80865f041e2d2