/** * @covers \Magento\Framework\Escaper::escapeJsQuote */ public function testEscapeJsQuote() { $data = ["Don't do that.", 'lost_key' => "Can't do that."]; $expected = ["Don\\'t do that.", "Can\\'t do that."]; $this->assertEquals($expected, $this->_escaper->escapeJsQuote($data)); $this->assertEquals($expected[0], $this->_escaper->escapeJsQuote($data[0])); }
/** * {@inheritdoc} */ public function getSectionData() { $customerId = $this->currentCustomer->getCustomerId(); if ($this->paypalData->shouldAskToCreateBillingAgreement($this->config, $customerId)) { return ['askToCreate' => true, 'confirmUrl' => $this->escaper->escapeUrl($this->urlBuilder->getUrl($this->startAction, [\Magento\Paypal\Model\Express\Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT => 1])), 'confirmMessage' => $this->escaper->escapeJsQuote(__('Would you like to sign a billing agreement to streamline further purchases with PayPal?'))]; } return []; }
public function getEditFormField() { $lines = []; $tab = $this->getPadding(); $eol = $this->getEol(); $lines[] = '$fieldset->addField('; $lines[] = $tab . '\'' . $this->getAttribute()->getCode() . '\','; $lines[] = $tab . '\'' . $this->getEditFormType() . '\','; $lines[] = $tab . '['; $lines[] = $tab . $tab . '\'name\' => \'' . $this->getAttribute()->getCode() . '\','; $lines[] = $tab . $tab . '\'label\' => __(\'' . $this->getAttribute()->getLabel() . '\'),'; $lines[] = $tab . $tab . '\'title\' => __(\'' . $this->getAttribute()->getLabel() . '\'),'; if ($this->getAttribute()->getRequired()) { $lines[] = $tab . $tab . '\'required\' => true,'; } if ($note = $this->getAttribute()->getNote()) { $lines[] = $tab . $tab . '\'note\' => __(\'' . $this->escaper->escapeJsQuote($note) . '\'),'; } foreach ($this->getAdditionalEditFormOptions() as $option) { $lines[] = $tab . $tab . $option; } $lines[] = $tab . ']'; $lines[] = ');'; return $tab . $tab . implode($eol . $tab . $tab, $lines) . $eol; }
/** * Escape quotes in java scripts * * @param string|array $data * @param string $quote * @return string|array */ public function escapeJsQuote($data, $quote = '\'') { return $this->_escaper->escapeJsQuote($data, $quote); }