Skip to content

Commit 731ecda

Browse files
committed
Fixed security issue
1 parent c4aaf73 commit 731ecda

File tree

11 files changed

+47
-3
lines changed

11 files changed

+47
-3
lines changed

LICENSE.txt

100644100755
File mode changed.

includes/frontend/class-breadcrumbs.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace WebberZone\Knowledge_Base\Frontend;
99

10+
use WebberZone\Knowledge_Base\Util\Helpers;
11+
1012
if ( ! defined( 'WPINC' ) ) {
1113
die;
1214
}
@@ -50,6 +52,7 @@ public static function get_breadcrumb( $args = array() ) {
5052

5153
// Parse incoming $args into an array and merge it with $defaults.
5254
$args = wp_parse_args( $args, $defaults );
55+
$args = Helpers::sanitize_args( $args );
5356

5457
// Convert Unicode sequence if provided.
5558
if ( strpos( $args['separator'], '\\' ) === 0 ) {
@@ -139,6 +142,7 @@ private static function get_hierarchical_term_trail( \WP_Term $taxonomy, $args =
139142
);
140143

141144
$args = wp_parse_args( $args, $defaults );
145+
$args = Helpers::sanitize_args( $args );
142146

143147
$output = '<li class="wzkb_breadcrumb-item" data-separator="' . esc_attr( $args['separator'] ) . '" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">';
144148
$output .= '<a href="' . esc_url( get_term_link( $taxonomy ) ) . '" itemprop="item" title="' . esc_attr( $taxonomy->name ) . '">';

includes/frontend/class-display.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace WebberZone\Knowledge_Base\Frontend;
99

1010
use WebberZone\Knowledge_Base\Util\Cache;
11+
use WebberZone\Knowledge_Base\Util\Helpers;
1112

1213
if ( ! defined( 'WPINC' ) ) {
1314
die;
@@ -64,6 +65,7 @@ public static function get_knowledge_base( $args = array() ) {
6465
);
6566

6667
$args = wp_parse_args( $args, $defaults );
68+
$args = Helpers::sanitize_args( $args );
6769

6870
// Set defaults if variables are empty.
6971
$args['limit'] = ( ! empty( absint( $args['limit'] ) ) ) ? absint( $args['limit'] ) : \wzkb_get_option( 'limit' );
@@ -379,6 +381,7 @@ public static function get_categories_list( $term_id, $level = 0, $args = array(
379381
);
380382

381383
$args = wp_parse_args( $args, $defaults );
384+
$args = Helpers::sanitize_args( $args );
382385

383386
// Get Knowledge Base Sections.
384387
$sections = get_terms(

includes/functions.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use WebberZone\Knowledge_Base\Frontend\Media_Handler;
99
use WebberZone\Knowledge_Base\Frontend\Related;
10+
use WebberZone\Knowledge_Base\Util\Helpers;
1011

1112
// If this file is called directly, abort.
1213
if ( ! defined( 'WPINC' ) ) {
@@ -102,8 +103,9 @@ function wzkb_get_alert( $args = array(), $content = '' ) {
102103

103104
// Parse incomming $args into an array and merge it with $defaults.
104105
$args = wp_parse_args( $args, $defaults );
106+
$args = Helpers::sanitize_args( $args );
105107

106-
$type = 'wzkb-alert-' . $args['type'];
108+
$type = 'wzkb-alert-' . sanitize_html_class( $args['type'] );
107109

108110
$class = implode( ' ', explode( ',', $args['class'] ) );
109111
$class = $type . ' ' . $class;
@@ -161,6 +163,7 @@ function wzkb_get_the_post_thumbnail( $args = array() ) {
161163

162164
// Parse incomming $args into an array and merge it with $defaults.
163165
$args = wp_parse_args( $args, $defaults );
166+
$args = Helpers::sanitize_args( $args );
164167

165168
return Media_Handler::get_the_post_thumbnail( $args );
166169
}
@@ -180,6 +183,7 @@ function wzkb_related_articles( $args = array() ) {
180183
);
181184

182185
$args = wp_parse_args( $args, $defaults );
186+
$args = Helpers::sanitize_args( $args );
183187

184188
$related = Related::get_related_articles( $args );
185189

includes/util/class-helpers.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,32 @@ public static function get_credit_link() {
4444

4545
return $output;
4646
}
47+
48+
/**
49+
* Sanitize args.
50+
*
51+
* @since 2.3.1
52+
*
53+
* @param array $args Array of arguments.
54+
* @return array Sanitized array of arguments.
55+
*/
56+
public static function sanitize_args( $args ): array {
57+
foreach ( $args as $key => $value ) {
58+
if ( is_string( $value ) ) {
59+
switch ( $key ) {
60+
case 'class':
61+
case 'className':
62+
case 'extra_class':
63+
$classes = explode( ' ', $value );
64+
$sanitized_classes = array_map( 'sanitize_html_class', $classes );
65+
$args[ $key ] = implode( ' ', $sanitized_classes );
66+
break;
67+
default:
68+
$args[ $key ] = wp_kses_post( $value );
69+
break;
70+
}
71+
}
72+
}
73+
return $args;
74+
}
4775
}

includes/widgets/index.php

100644100755
File mode changed.

index.php

100644100755
File mode changed.

knowledgebase.php

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Plugin Name: WebberZone Knowledge Base
1414
* Plugin URI: https://github.com/WebberZone/knowledgebase
1515
* Description: Create a multi-product knowledge base on your WordPress site.
16-
* Version: 2.3.0
16+
* Version: 2.3.1-beta1
1717
* Author: WebberZone
1818
* Author URI: https://webberzone.com
1919
* License: GPL-2.0+

languages/index.php

100644100755
File mode changed.

readme.txt

100644100755
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: Ajay, webberzone
33
Donate link: https://ajaydsouza.com/donate/
44
Tags: knowledge base, knowledgebase, FAQ, frequently asked questions, support, documentation
55
Requires at least: 6.3
6-
Tested up to: 6.7
6+
Tested up to: 6.8
77
Requires PHP: 7.4
88
Stable tag: 2.3.0
99
License: GPLv2 or later
@@ -118,6 +118,11 @@ Completely rewritten. Several new features and enhancements.
118118

119119
== Changelog ==
120120

121+
= 2.3.1 =
122+
123+
* Bug fixes:
124+
* Fixed security issue where arguments passed to the shortcodes were not properly sanitized.
125+
121126
= 2.3.0 =
122127

123128
Release post: [https://webberzone.com/blog/knowledge-base-v2-3-0/](https://webberzone.com/blog/knowledge-base-v2-3-0/)

0 commit comments

Comments
 (0)