Skip to content

Commit

Permalink
fixes the scan post function
Browse files Browse the repository at this point in the history
  • Loading branch information
ata-no-one committed Oct 18, 2024
1 parent a61d6bb commit d515723
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
1 change: 0 additions & 1 deletion .devcontainer/configureWordPress.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ do
echo "waiting for WordPress to be installed"
sleep 2
done
composer install

docker exec -it --user www-data gdata-antivirus-app-1 bash -c "wp plugin uninstall hello"
docker exec -it --user www-data gdata-antivirus-app-1 bash -c "wp plugin uninstall akismet"
Expand Down
9 changes: 9 additions & 0 deletions Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ While the released code is hosted on the WordPress svn, we develop the plugin on

== Changelog ==

= 2.0.8 =
* bugfix: posts could not be saved

= 2.0.7 =
* enable upload scan by removing the nonce check temporary

= 2.0.6 =
* changed the full scan indicator. the counting method was error prone

= 2.0.5 =
* don't connect to the backend for every page load

Expand Down
13 changes: 4 additions & 9 deletions Vaas/ScanClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct(

$post_scan_enabled = (bool) get_option('gdatacyberdefenseag_antivirus_options_on_demand_scan_post_scan_enabled', true);
if ($post_scan_enabled === true) {
add_filter('wp_insert_post_data', array( $this, 'scan_post' ), 10, 3);
add_filter('wp_insert_post_data', array( $this, 'scan_post' ), 10, 1);
}
}

Expand Down Expand Up @@ -87,8 +87,7 @@ public function connect() {
$this->connected = true;
}

public function scan_post( $data, $postdata, $unsanitized_postarr ) {
$data = wp_unslash($unsanitized_postarr);
public function scan_post( $data ) {
if (empty($data['post_content'])) {
return $data;
}
Expand All @@ -98,11 +97,7 @@ public function scan_post( $data, $postdata, $unsanitized_postarr ) {
return $data;
}

if (empty($postdata['post_content'])) {
return $data;
}

$post_content = wp_unslash($postdata['post_content']);
$post_content = wp_unslash($data['post_content']);
$stream = $this->file_system->get_resource_stream_from_string($post_content);

$this->connect();
Expand All @@ -128,7 +123,7 @@ public function scan_post( $data, $postdata, $unsanitized_postarr ) {
$this->logger->debug('gdata-antivirus: virus found in post');
wp_die(esc_html__('virus found', 'gdata-antivirus'));
}
return $postdata;
return $data;
}

public function scan_comment( $commentdata ) {
Expand Down
6 changes: 4 additions & 2 deletions scoper.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/bin/bash
set -e

composer install --no-dev
rm -rf scoped-code/
php-scoper add-prefix
composer install --no-dev
php-scoper add-prefix --force
composer install --no-dev

mv scoped-code/vendor/netresearch/jsonmapper/src/JsonMapper/Exception.php scoped-code/vendor/netresearch/jsonmapper/src/JsonMapper/JsonMapper_Exception.php
mv scoped-code/vendor/netresearch/jsonmapper/src/JsonMapper.php scoped-code/vendor/netresearch/jsonmapper/src/JsonMapper/JsonMapper.php
composer dump-autoload --working-dir scoped-code/ --classmap-authoritative

0 comments on commit d515723

Please sign in to comment.