diff --git a/bridges/VkBridge.php b/bridges/VkBridge.php
index 7f5ae1c8..713b86f3 100644
--- a/bridges/VkBridge.php
+++ b/bridges/VkBridge.php
@@ -239,6 +239,41 @@ class VkBridge extends BridgeAbstract
$a->outertext = '';
}
+ // fix links and get post hashtags
+ $hashtags = array();
+ foreach($post->find('a') as $a) {
+ $href = $a->getAttribute('href');
+ $innertext = $a->innertext;
+
+ $hashtag_prefix = '/feed?section=search&q=%23';
+ $hashtag = null;
+
+ if ($href && substr($href, 0, strlen($hashtag_prefix)) === $hashtag_prefix) {
+ $hashtag = urldecode(substr($href, strlen($hashtag_prefix)));
+ } else if (substr($innertext, 0, 1) == '#') {
+ $hashtag = $innertext;
+ }
+
+ if ($hashtag) {
+ $a->outertext = $innertext;
+ $hashtags[] = $hashtag;
+ continue;
+ }
+
+ $parsed_url = parse_url($href);
+
+ if (array_key_exists('path', $parsed_url) === false) continue;
+
+ if (strpos($parsed_url['path'], '/away.php') === 0) {
+ parse_str($parsed_url['query'], $parsed_query);
+ $a->setAttribute('href', iconv(
+ 'windows-1251',
+ 'utf-8//ignore',
+ $parsed_query['to']
+ ));
+ }
+ }
+
if (is_object($post->find('div.copy_quote', 0))) {
if ($this->getInput('hide_reposts') === true) {
continue;
@@ -252,21 +287,9 @@ class VkBridge extends BridgeAbstract
}
$item = array();
- $item['content'] = strip_tags(backgroundToImg($post->find('div.wall_text', 0)->innertext), '
');
+ $item['content'] = strip_tags(backgroundToImg($post->find('div.wall_text', 0)->innertext), '
');
$item['content'] .= $content_suffix;
- $item['categories'] = array();
-
- // get post hashtags
- foreach($post->find('a') as $a) {
- $href = $a->getAttribute('href');
- $prefix = '/feed?section=search&q=%23';
- $innertext = $a->innertext;
- if ($href && substr($href, 0, strlen($prefix)) === $prefix) {
- $item['categories'][] = urldecode(substr($href, strlen($prefix)));
- } else if (substr($innertext, 0, 1) == '#') {
- $item['categories'][] = $innertext;
- }
- }
+ $item['categories'] = $hashtags;
// get post link
$post_link = $post->find('a.post_link', 0)->getAttribute('href');