/** * Tests enforcing XHTML links. * * @return void */ public function testLinkXHTMLSafe() { $this->assertEquals( '<a href="http://www.example.com/index.frd?one=1&two=2&three=3">This & That</a>', $this->object->linkXHTMLSafe('<a href="http://www.example.com/index.frd?one=1&two=2&three=3">This & That</a>'), 'Should clean ampersands only out of link, not out of link text' ); }
function filter($filterme) { return JFilterOutput::linkXHTMLSafe($filterme); }
function _bindData($verbose = true) { $option = 'com_rsmembership'; jimport('joomla.mail.helper'); $return = true; $post = JRequest::get('post'); if (empty($post)) { return false; } $this->_data = new stdClass(); $user =& JFactory::getUser(); $choose_username = RSMembershipHelper::getConfig('choose_username'); if ($choose_username) { $post['username'] = str_replace('-', '_', JFilterOutput::linkXHTMLSafe(@$post['username'])); if ($user->get('guest')) { if (empty($post['username']) || strlen($post['username']) < 2) { if ($verbose) { JError::raiseWarning(500, JText::_('RSM_PLEASE_TYPE_USERNAME')); } $return = false; } $this->_db->setQuery("SELECT id FROM #__users WHERE username='******'username']) . "'"); if ($this->_db->loadResult()) { if ($verbose) { JError::raiseWarning(500, JText::_('RSM_USERNAME_NOT_OK')); } $return = false; } } $this->_data->username = $user->get('guest') ? @$post['username'] : $user->get('username'); } $choose_password = RSMembershipHelper::getConfig('choose_password'); if ($choose_password) { $password = JRequest::getVar('password', '', 'default', 'none', JREQUEST_ALLOWRAW); $password2 = JRequest::getVar('password2', '', 'default', 'none', JREQUEST_ALLOWRAW); if ($user->get('guest')) { if (!strlen($password)) { if ($verbose) { JError::raiseWarning(500, JText::_('RSM_PLEASE_TYPE_PASSWORD')); } $return = false; } elseif (strlen($password) < 6) { if ($verbose) { JError::raiseWarning(500, JText::_('RSM_PLEASE_TYPE_PASSWORD_6')); } $return = false; } elseif ($password != $password2) { if ($verbose) { JError::raiseWarning(500, JText::_('RSM_PLEASE_CONFIRM_PASSWORD')); } $return = false; } } $this->_data->password = $user->get('guest') ? md5($password) : ''; } if ($user->get('guest') && empty($post['name'])) { if ($verbose) { JError::raiseWarning(500, JText::_('RSM_PLEASE_TYPE_NAME')); } $return = false; } $this->_data->name = $user->get('guest') ? @$post['name'] : $user->get('name'); if ($user->get('guest') && (empty($post['email']) || !JMailHelper::isEmailAddress($post['email']))) { if ($verbose) { JError::raiseWarning(500, JText::_('RSM_PLEASE_TYPE_EMAIL')); } $return = false; } $this->_data->email = $user->get('guest') ? @$post['email'] : $user->get('email'); $db =& JFactory::getDBO(); $db->setQuery("SELECT * FROM #__rsmembership_fields WHERE (required='1' OR `rule` != '') AND published='1' ORDER BY ordering"); $fields = $db->loadObjectList(); foreach ($fields as $field) { if ($field->required && empty($post['rsm_fields'][$field->name]) || $field->rule && !empty($post['rsm_fields'][$field->name]) && is_callable('RSMembershipValidation', $field->rule) && !call_user_func(array('RSMembershipValidation', $field->rule), @$post['rsm_fields'][$field->name])) { $validation_message = JText::_($field->validation); if (empty($validation_message)) { $validation_message = JText::sprintf('RSM_VALIDATION_DEFAULT_ERROR', JText::_($field->label)); } if ($verbose) { JError::raiseWarning(500, $validation_message); } $return = false; } } $this->_data->fields = @$post['rsm_fields']; // coupon $this->_data->coupon = JRequest::getVar('coupon'); $captcha_enabled = RSMembershipHelper::getConfig('captcha_enabled'); $use_captcha = $this->getUseCaptcha(); if ($use_captcha && $captcha_enabled && $verbose) { if ($captcha_enabled == 1) { if (!class_exists('JSecurImage')) { require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_rsmembership' . DS . 'helpers' . DS . 'securimage' . DS . 'securimage.php'; } $captcha_image = new JSecurImage(); $valid = $captcha_image->check($post['captcha']); if (!$valid) { JError::raiseNotice(500, JText::_('RSM_CAPTCHA_ERROR')); $return = false; } } elseif ($captcha_enabled == 2) { if (!class_exists('JReCAPTCHA')) { require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_rsmembership' . DS . 'helpers' . DS . 'recaptcha' . DS . 'recaptchalib.php'; } $privatekey = RSMembershipHelper::getConfig('recaptcha_private_key'); $response = JReCAPTCHA::checkAnswer($privatekey, @$_SERVER['REMOTE_ADDR'], @$post['recaptcha_challenge_field'], @$post['recaptcha_response_field']); if ($response === false || !$response->is_valid) { $this->recaptcha_error = @$response->error; JError::raiseNotice(500, JText::_('RSM_CAPTCHA_ERROR')); $return = false; } } } $session = JFactory::getSession(); $session->set($option . '.subscribe.data', $this->_data); return $return; }
/** * Helper wrapper method for linkXHTMLSafe * * @param string $input String to process. * * @return string Processed string. * * @see JFilterOutput::linkXHTMLSafe() * @since 3.4 */ public function linkXHTMLSafe($input) { return JFilterOutput::linkXHTMLSafe($input); }