Skip to content

Commit bb6997a

Browse files
committed
Fix validation issues
ADPM-119
1 parent 0c826a5 commit bb6997a

File tree

6 files changed

+65
-2
lines changed

6 files changed

+65
-2
lines changed

dist/deploy.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ rm -rf ./adyenofficial
99
echo -e "\e[32mSTEP 1:\e[0m Copying plugin source..."
1010
mkdir adyenofficial
1111
cp -r ./src/* adyenofficial
12+
cp ./src/.htaccess adyenofficial/
1213

1314
cd ./adyenofficial
1415
echo -e "\e[32mSTEP 2:\e[0m Installing composer dependencies..."
@@ -28,12 +29,15 @@ rm -rf ./adyenofficial/vendor/adyen/php-webhook-module/.github
2829
rm -rf ./adyenofficial/controllers/front/test.php
2930
rm -rf ./adyenofficial/classes/E2ETest
3031
rm -rf ./adyenofficial/vendor/adyen/integration-core/src/BusinessLogic/E2ETest
32+
rm -rf ./adyenofficial/vendor/adyen/integration-core/src/Infrastructure/Serializer/Concrete/NativeSerializer.php
3133

32-
echo -e "\e[32mSTEP 4:\e[0m Adding PrestaShop mandatory index.php file to all folders..."
34+
echo -e "\e[32mSTEP 4:\e[0m Adding PS version check in every PHP file"
35+
./dist/scripts/check_ps_version.sh
36+
echo -e "\e[32mSTEP 5:\e[0m Adding PrestaShop mandatory index.php file to all folders..."
3337
php "$PWD/lib/autoindex/index.php" "$PWD/adyenofficial" >/dev/null
3438

3539
# Create plugin archive
36-
echo -e "\e[32mSTEP 5:\e[0m Creating new archive..."
40+
echo -e "\e[32mSTEP 6:\e[0m Creating new archive..."
3741
zip -r -q adyenofficial.zip ./adyenofficial
3842

3943
echo -e "\e[93mNew plugin archive created: $PWD/adyenofficial.zip"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
path="$1"
4+
code_to_add="$2"
5+
6+
find "$path" -type f -name "*.php" | while read -r file; do
7+
# Add PS version check after first line (<?php line)
8+
awk -v code="$code_to_add" '
9+
{
10+
if ($0 ~ /^<\?php/) {
11+
print $0 "\n\n" code;
12+
} else {
13+
print $0;
14+
}
15+
}' "$file" > temp && mv temp "$file"
16+
done
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
path="$1"
4+
code_to_add="$2"
5+
6+
find "$path" -type f -name "*.php" | while read -r file; do
7+
# Add PS version check after namespace line
8+
awk -v code="$code_to_add" '
9+
{
10+
if ($0 ~ /^namespace /) {
11+
print $0 "\n\n" code;
12+
} else {
13+
print $0;
14+
}
15+
}' "$file" > temp && mv temp "$file"
16+
done

dist/scripts/check_ps_version.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
code_to_add="if (!defined('_PS_VERSION_')) {
4+
exit;
5+
}"
6+
7+
./dist/scripts/add_ps_version_check_after_namespace.sh "./adyenofficial" "$code_to_add"
8+
./dist/scripts/add_ps_version_check_after_first_line.sh "./adyenofficial/controllers/admin" "$code_to_add"
9+
./dist/scripts/add_ps_version_check_after_first_line.sh "./adyenofficial/controllers/front" "$code_to_add"
10+
./dist/scripts/add_ps_version_check_after_first_line.sh "./adyenofficial/override" "$code_to_add"
11+
./dist/scripts/add_ps_version_check_after_first_line.sh "./adyenofficial/translations" "$code_to_add"

lib/autoindex/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ function addIndex($path, $cli = false)
5555
{
5656
$is_dot = array('.', '..');
5757
$file_extension = substr(strrchr($path, '.'), 1);
58+
copyFile(dirname(__FILE__) . '/sources/index.php', $path . '/index.php');
5859
if (is_dir($path)) {
5960
if (__PHP53__) {
6061
$iterator = new RecursiveIteratorIterator(

src/.htaccess

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Module root .htaccess
2+
# Apache 2.4
3+
<IfModule mod_authz_core.c>
4+
<Files *.php>
5+
Require all denied
6+
</Files>
7+
</IfModule>
8+
9+
# Apache 2.2
10+
<IfModule !mod_authz_core.c>
11+
<Files *.php>
12+
Order allow,deny
13+
Deny from all
14+
</Files>
15+
</IfModule>

0 commit comments

Comments
 (0)