Menu

#155 bad find() results because of '{'

closed
None
2018-12-06
2016-03-17
No

Exemple HTML

<html><body><table>
    <tr><td><div>12{X]</div></td></tr>
    <tr><td><div>13{D}</div></td></tr>
</table></body></html>

running:

$dom = str_get_html($exemple);
$res = $dom->find("td/div", 0);
var_dump($res->plaintext);

result:

string(55) "12{X]</div></td></tr>     <tr><td><div>13{D}" 

remove '{' in 1st div
or '}' in 2nd div
or replace ']' to '}' in 1st div

<html><body><table>
    <tr><td><div>[12X]</div></td></tr>
    <tr><td><div>13{D}</div></td></tr>
</table></body></html>

and result will be ok

string(4) "[12X]" 

Discussion

  • peter

    peter - 2016-03-19

    Same with the bug I found https://sourceforge.net/p/simplehtmldom/bugs/154/

    Do you solve it ?

    This support form is dead. We must solve it by ourselves.

     
  • schildmi

    schildmi - 2016-03-28

    Hi,

    I have the same problem and find a solution.

    I put in the following code in the file "simple_html_dom.php" in the "protected function prepare" after "$this->original_size = $this->size;"

    $str = str_replace("{", "{", $str);
    $str = str_replace("}", "}", $str);

    It's a little bit ugly, but it works.

     
    • peter

      peter - 2016-03-29

      thank you very much.

       
  • LogMANOriginal

    LogMANOriginal - 2018-12-05
    • status: open --> closed
    • assigned_to: LogMANOriginal
     
  • LogMANOriginal

    LogMANOriginal - 2018-12-05

    [e60ffe] was recently added to master, which solves your issue (same as #154). Please let me know if you experience futher problems.

     

    Related

    Commit: [e60ffe]


Log in to post a comment.

MongoDB Logo MongoDB