1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-08-06 00:27:27 +02:00

Revert "all: Use ->remove() instead of ->outertext = ''"

This reverts commit 052844f5e1.

There is a bug in ->remove() that causes the parser to incorrectly
identify elements in the DOM tree that shouldn't exist anymore.

References #1151
This commit is contained in:
logmanoriginal
2019-06-02 13:03:26 +02:00
parent 468d8be72d
commit 6c4098d655
21 changed files with 49 additions and 44 deletions

View File

@@ -62,8 +62,9 @@ class VkBridge extends BridgeAbstract
$this->pageName = htmlspecialchars_decode($pageName);
}
foreach ($html->find('div.replies') as $comment_block) {
$comment_block->remove();
$comment_block->outertext = '';
}
$html->load($html->save());
$pinned_post_item = null;
$last_post_id = 0;
@@ -81,7 +82,7 @@ class VkBridge extends BridgeAbstract
if (is_object($post->find('a.wall_post_more', 0))) {
//delete link "show full" in content
$post->find('a.wall_post_more', 0)->remove();
$post->find('a.wall_post_more', 0)->outertext = '';
}
$content_suffix = '';
@@ -113,7 +114,7 @@ class VkBridge extends BridgeAbstract
foreach($external_link_selectors_to_remove as $sel) {
if (is_object($post->find($sel, 0))) {
$post->find($sel, 0)->remove();
$post->find($sel, 0)->outertext = '';
}
}
@@ -139,7 +140,7 @@ class VkBridge extends BridgeAbstract
$content_suffix .= "<br><img src='" . $matches[1] . "'>";
}
$content_suffix .= "<br>Article: <a href='$article_link'>$article_title ($article_author)</a>";
$article->remove();
$article->outertext = '';
}
// get video on post
@@ -149,7 +150,7 @@ class VkBridge extends BridgeAbstract
$video_title = $video->find('div.post_video_title', 0)->plaintext;
$video_link = $video->find('a.lnk', 0)->getAttribute('href');
$this->appendVideo($video_title, $video_link, $content_suffix, $post_videos);
$video->remove();
$video->outertext = '';
$main_video_link = $video_link;
}
@@ -160,14 +161,14 @@ class VkBridge extends BridgeAbstract
if (count($temp) > 1) $video_title = $temp[1];
$video_link = $a->getAttribute('href');
if ($video_link != $main_video_link) $this->appendVideo($video_title, $video_link, $content_suffix, $post_videos);
$a->remove();
$a->outertext = '';
}
// get all photos
foreach($post->find('div.wall_text > a.page_post_thumb_wrap') as $a) {
$result = $this->getPhoto($a);
if ($result == null) continue;
$a->remove();
$a->outertext = '';
$content_suffix .= "<br>$result";
}
@@ -176,7 +177,7 @@ class VkBridge extends BridgeAbstract
$a = $el->find('.page_album_link', 0);
$album_title = $a->find('.page_album_title_text', 0)->getAttribute('title');
$album_link = $a->getAttribute('href');
$el->remove();
$el->outertext = '';
$content_suffix .= "<br>Album: <a href='$album_link'>$album_title</a>";
}
@@ -199,7 +200,7 @@ class VkBridge extends BridgeAbstract
}
$a->remove();
$a->outertext = '';
}
// get other documents
@@ -216,7 +217,7 @@ class VkBridge extends BridgeAbstract
}
$div->remove();
$div->outertext = '';
}
// get polls
@@ -226,14 +227,14 @@ class VkBridge extends BridgeAbstract
foreach($div->find('div.page_poll_text') as $poll_stat_title) {
$content_suffix .= '<br>- ' . $poll_stat_title->innertext;
}
$div->remove();
$div->outertext = '';
}
// get sign
$post_author = $pageName;
foreach($post->find('a.wall_signed_by') as $a) {
$post_author = $a->innertext;
$a->remove();
$a->outertext = '';
}
if (is_object($post->find('div.copy_quote', 0))) {
@@ -242,7 +243,7 @@ class VkBridge extends BridgeAbstract
}
$copy_quote = $post->find('div.copy_quote', 0);
if ($copy_post_header = $copy_quote->find('div.copy_post_header', 0)) {
$copy_post_header->remove();
$copy_post_header->outertext = '';
}
$copy_quote_content = $copy_quote->innertext;
$copy_quote->outertext = "<br>Reposted: <br>$copy_quote_content";