voku/simple_html_dom

Href parameter is not being set correctly

ekr3peeK opened this issue · 2 comments

What is this feature about (expected vs actual behaviour)?

Right now I am unable to change the href attribute of an <a> tag when the new link would contain another link as a parameter.

How can I reproduce it?

You can reproduce this with this small code snippet:

$document = \voku\helper\HtmlDomParser::str_get_html("<a href='https://test.com?param1=1&param2=2'></a>");
$link = $document->find('a');
$link[0]->setAttribute('href', 'https://redirect.com?rdr=' . urlencode($link[0]->getAttribute('href')));

echo "Desired: <a href='https://redirect.com?rdr=" . urlencode($link[0]->getAttribute('href')) . "'></a>\n";
echo "Result: " . $document->save();
exit;

Is this a configuration problem on my part, or an actual bug?

voku commented

Thanks for the bug report, and yes, it was a bug. Fixed in version 4.7.26.

Happy Coding! 👍