Skip to content

Commit c3e420d

Browse files
committed
Updated version and enhanced security
- Bumped up the version number in multiple files - Added nonce verification for form submission to enhance security - Escaped HTML output in various places to prevent potential XSS attacks - Fixed some minor issues with input fields and select options
1 parent cef0c82 commit c3e420d

File tree

10 files changed

+28
-19
lines changed

10 files changed

+28
-19
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "simpay/simpay-wordpress",
3-
"version": "2.2.3",
3+
"version": "2.2.4",
44
"type": "library",
55
"require": {
66
"simpaypl/simpay": "^2.2"

readme.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Donate link: https://darkgl.pl/
44
Tags: simpay, payments, directbiling, sms
55
Requires at least: 6.0
66
Tested up to: 6.6.1
7-
Stable tag: 2.2.3
7+
Stable tag: 2.2.4
88
Requires PHP: 8.1
99
License: GPLv2 or later
1010
License URI: https://www.gnu.org/licenses/gpl-2.0.html

simpay-wordpress.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Plugin Name: SimPay Wordpress
55
* Plugin URI: https://simpay.pl
66
* Description: Use SimPay SMS service to use during registration or access to the post.
7-
* Version: 2.2.3
7+
* Version: 2.2.4
88
* Author: SimPay
99
* Author URI: https://simpay.pl
1010
* License: GPL-2.0+

src/Modules/PaywallMode/Hooks/AddPaywallOnPost.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ private function showNotLoggedInAlert(): string
8585
*/
8686
private function handlePaywallForm(mixed $wpQuery): ?string
8787
{
88+
if (!isset($_POST['_simpay_nonce']) || !wp_verify_nonce($_POST['_simpay_nonce'], 'simpay_paywall_nonce')) {
89+
return '';
90+
}
91+
8892
if (isset($_POST['sms_code'])) {
8993
if ($error = $this->validateSmsForm()) {
9094
$this->renderSimPayPaymentForm(get_the_ID(), $error);
@@ -138,6 +142,7 @@ public function renderSimPayPaymentForm(int $postId, string $error = null): void
138142
'smsNumber' => $smsNumber->getNumber(),
139143
'smsPrice' => $smsNumber->getPriceGross(),
140144
'smsCode' => $this->simPayService->getSmsCode()->getCode(),
145+
'_simpay_nonce' => wp_create_nonce('simpay_paywall_nonce'),
141146
]);
142147
}
143148

view/admin/settings/partials/field-checkbox.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
<input
66
id="<?php echo esc_html($args['name']); ?>"
77
type="checkbox"
8-
name="<?php echo $args['name']; ?>"
8+
name="<?php echo esc_html($args['name']); ?>"
99
<?php echo $args['value'] ? 'checked' : ''; ?>>

view/admin/settings/partials/field-input.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
$args = array_merge($defaultArgs, $args);
1414
?>
1515

16-
<input id="<?php echo $args['name']; ?>"
17-
type="<?php echo $args['type']; ?>"
18-
type="<?php echo $args['value']; ?>"
19-
name="<?php echo $args['name']; ?>"
20-
placeholder="<?php echo $args['placeholder']; ?>"
21-
value="<?php echo $args['value']; ?>">
16+
<input
17+
id="<?php echo esc_html($args['name']); ?>"
18+
type="<?php echo esc_html($args['type']); ?>"
19+
type="<?php echo esc_html($args['value']); ?>"
20+
name="<?php echo esc_html($args['name']); ?>"
21+
placeholder="<?php echo esc_html($args['placeholder']); ?>"
22+
value="<?php echo esc_html($args['value']); ?>">

view/admin/settings/partials/field-select.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ class='post_form'
2121
$disabledReason = '';
2222
}
2323
?>
24-
<option value="<?php echo $optionValue; ?>" <?php echo $checked; ?><?php echo $disabled; ?>>
25-
<?php echo $optionTitle; ?>
26-
<?php echo $disabledReason; ?>
24+
<option value="<?php echo esc_html($optionValue); ?>" <?php echo esc_html($checked); ?><?php echo esc_html($disabled); ?>>
25+
<?php echo esc_html($optionTitle); ?>
26+
<?php echo esc_html($disabledReason); ?>
2727
</option>
2828
<?php } ?>
2929
</select>

view/public/paywall/access-denied-alert.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<p>Dostęp do treści na tej stronie jest zarezerwowany tylko dla płatnych użytkowników.</p>
88
<?php if (isset($error) && null !== $error) { ?>
99
<p>
10-
<?php echo $error; ?>
10+
<?php echo esc_html($error); ?>
1111
</p>
1212
<?php } ?>
1313
<?php if (isset($showNotLoggedInInfo) && true === $showNotLoggedInInfo) { ?>

view/public/paywall/payment-form.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
<div class="simpay-paywall-payment-form">
66
<p class="message">
77
Aby uzyskać dostęp, wyślij SMS na numer
8-
<strong><?php echo $smsNumber; ?></strong> o treści
9-
<strong><?php echo $smsCode; ?></strong>. Koszt SMS to
10-
<strong><?php echo $smsPrice; ?> zł (brutto)</strong>
8+
<strong><?php echo esc_html($smsNumber); ?></strong> o treści
9+
<strong><?php echo esc_html($smsCode); ?></strong>. Koszt SMS
10+
to
11+
<strong><?php echo esc_html($smsPrice); ?>
12+
(brutto)</strong>
1113
</p>
1214
<form method="post">
15+
<?php wp_nonce_field('simpay_paywall_nonce', '_simpay_nonce'); ?>
1316
<input type="text" name="sms_code" id="sms_code" class="input" size="25" placeholder="Kod SMS" required />
1417
<input type="hidden" name="post_id"
1518
value="<?php echo esc_html($postId); ?>">

view/public/register/register-form.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
<p class="message">
66
Aby się zarejestrować, wyślij SMS <br>na numer
7-
<strong><?php echo $smsNumber; ?></strong><br>
8-
o treści <strong><?php echo $smsCode; ?></strong>.<br>
7+
<strong><?php echo esc_html($smsNumber); ?></strong><br>
8+
o treści <strong><?php echo esc_html($smsCode); ?></strong>.<br>
99
Koszt SMS to <strong><?php echo esc_html($smsPrice); ?>
1010
(brutto)</strong>
1111
</p>

0 commit comments

Comments
 (0)