@@ -137,7 +137,7 @@ public function my_bulk_action_handler( $redirect_to, $doaction, $post_ids ) {
137137 return $ redirect_to ;
138138 }
139139 // stop if the action is not of bulk printing.
140- if ( ! in_array ( $ _REQUEST ['action ' ], array ( 'wcdn_print_invoice ' , 'wcdn_print_delivery-note ' , 'wcdn_print_receipt ' ) ) ) {
140+ if ( ! in_array ( $ _REQUEST ['action ' ], array ( 'wcdn_print_invoice ' , 'wcdn_print_delivery-note ' , 'wcdn_print_receipt ' ) ) ) { // phpcs:ignore
141141 return $ redirect_to ;
142142 }
143143 // only for specified actions.
@@ -207,21 +207,23 @@ public function confirm_bulk_actions() {
207207 if ( $ this ->is_order_edit_page () ) {
208208 foreach ( WCDN_Print::$ template_registrations as $ template_registration ) {
209209 if ( isset ( $ _REQUEST [ 'printed_ ' . $ template_registration ['type ' ] ] ) ) {
210+
210211 // use singular or plural form.
211- $ total = isset ( $ _REQUEST ['total ' ] ) ? absint ( $ _REQUEST ['total ' ] ) : 0 ;
212- if ( $ total <= 1 ) {
213- $ message = $ template_registration ['labels ' ]['message ' ];
214- } else {
215- $ message = $ template_registration ['labels ' ]['message_plural ' ];
216- }
217- ?>
212+ $ total = isset ( $ _REQUEST ['total ' ] ) ? absint ( $ _REQUEST ['total ' ] ) : 0 ;
213+ $ message = $ total <= 1 ? $ message = $ template_registration ['labels ' ]['message ' ] : $ template_registration ['labels ' ]['message_plural ' ];
218214
219- <div id="woocommerce-delivery-notes-bulk-print-message" class="updated">
220- <p><?php wp_kses_post ( $ message , 'woocommerce-delivery-notes ' ); ?>
221- <a href="<?php if ( isset ( $ _REQUEST ['print_url ' ] ) ) : echo urldecode ( esc_url_raw ( $ _REQUEST ['print_url ' ] ) ); endif ; // phpcs:ignore ?> " target="_blank" class="print-preview-button" id="woocommerce-delivery-notes-bulk-print-button"><?php esc_attr_e ( 'Print now ' , 'woocommerce-delivery-notes ' ); ?> </a> <span class="print-preview-loading spinner"></span></p>
222- </div>
215+ // Print URL - Fix Issue #214: Reflected XSS Vulnerability in Plugin.
216+ $ print_url = isset ( $ _REQUEST ['print_url ' ] ) ? $ _REQUEST ['print_url ' ] : '' ; // phpcs:ignore
217+ $ print_url = '' !== $ print_url && strtolower ( esc_url_raw ( $ print_url ) ) === strtolower ( $ print_url ) ? esc_url_raw ( $ print_url ) : '' ;
223218
224- <?php
219+ if ( '' !== $ print_url ) {
220+ ?>
221+ <div id="woocommerce-delivery-notes-bulk-print-message" class="updated">
222+ <p><?php wp_kses_post ( $ message , 'woocommerce-delivery-notes ' ); ?>
223+ <a href="<?php echo $ print_url ; // phpcs:ignore ?> " target="_blank" class="print-preview-button" id="woocommerce-delivery-notes-bulk-print-button"><?php esc_attr_e ( 'Print now ' , 'woocommerce-delivery-notes ' ); ?> </a> <span class="print-preview-loading spinner"></span></p>
224+ </div>
225+ <?php
226+ }
225227 break ;
226228 }
227229 }
@@ -269,7 +271,4 @@ public function create_box_content() {
269271 }
270272
271273 }
272-
273274}
274-
275- ?>
0 commit comments