Skip to content

Commit

Permalink
-Removendo short echo <?=
Browse files Browse the repository at this point in the history
-Protegendo contra injeção de javascript
-Removendo _ de método publico
  • Loading branch information
r-martins committed Jul 25, 2023
1 parent 8479329 commit 18bd310
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,14 @@ protected function _prepareLayout()
* Converte a messagem especificada em XML_PATH_PAYMENT_PAGSEGURO_CC_INSTALLMENT_PRODUCT_MESSAGE
* para exibição na página de produtos
*/
public function _messageToHTML()
public function messageToHTML()
{
$variables = array(
"num_parcelas" => "installments", /** Número de parcelas. Ex.: 12 */
"valor_parcela" => "installment_value", /** Preço da parcela do produto */
"valor_total" => "installment_total" /** Preço total do produto (com o valor dos juros incluso, caso haja) */
);

$message = Mage::getStoreConfig(
RicardoMartins_PagSeguro_Helper_Data::XML_PATH_PAYMENT_PAGSEGURO_CC_INSTALLMENT_PRODUCT_MESSAGE
);
Expand All @@ -80,6 +81,10 @@ public function _messageToHTML()
$message = str_replace("{".$variable."}", "<span id='$id'></span>", $message);
}

//remove potential javascript code, preserving php < 7.4 compatibility
$message = preg_replace('/<script\b[^>]*>(.*?)<\/script>/is', "", $message);


return $message;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
/** @var @var \RicardoMartins_PagSeguro_Block_Product_Installments $this */
/** @var RicardoMartins_PagSeguro_Helper_Data $_helper */
$_helper = Mage::helper('ricardomartins_pagseguro');
$_ajaxSessionIdUrl = Mage::getUrl('pseguro/ajax/getSessionId', array('_secure' => true));
$_price = $this->getPrice();
Expand All @@ -14,7 +16,7 @@ $_maxInstallmentNoInterest = $_helper->getMaxInstallmentsNoInterest($_price);

<div id="rmpagseguro_parcelas_box">
<p id="rmpagseguro_parcelas_loading">Carregando parcelas...</p>
<p id="pseguro_parcelas" style="display: none;"><?= $this->_messageToHTML() ?></p>
<p id="pseguro_parcelas" style="display: none;"><?php echo $this->messageToHTML() ?></p>
</div>

<script type="text/javascript">
Expand Down Expand Up @@ -51,13 +53,14 @@ $_maxInstallmentNoInterest = $_helper->getMaxInstallmentsNoInterest($_price);
if(maxInstallmentsConfig > 0 && maxInstallmentsConfig < responseVisa.length && maxInstallmentsConfig < installment.quantity){
installment = responseVisa[maxInstallmentsConfig - 1];
}
// debugger;
if ($('installments')) {
$('installments').innerHTML = installment.quantity.toString();
}
if ($('installments_value')) {
if ($('installment_value')) {
$('installment_value').innerHTML = installment.installmentAmount.toFixed(2).toString().replace('.', ',');
}
if ($('installments_total')) {
if ($('installment_total')) {
$('installment_total').innerHTML = installment.totalAmount.toFixed(2).toString().replace('.', ',');
if (installment.interestFree) {
$('installment_total').innerHTML += ' sem juros';
Expand Down

0 comments on commit 18bd310

Please sign in to comment.