non security modules update

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-20 16:32:07 +02:00
parent 6a8d30db08
commit 37fbabab56
466 changed files with 32690 additions and 9652 deletions

View File

@@ -1,10 +1,16 @@
span.ext {
background: url(extlink.png) right center no-repeat;
background: url(extlink_s.png) 2px center no-repeat;
width: 10px;
height: 10px;
padding-right: 12px;
text-decoration: none;
}
span.mailto {
background: url(mailto.png) right center no-repeat;
background: url(extlink_s.png) -20px center no-repeat;
width: 10px;
height: 10px;
padding-right: 12px;
text-decoration: none;
}
/* Hide the extra spans when printing. */

View File

@@ -6,9 +6,9 @@ configure = admin/config/user-interface/extlink
stylesheets[all][] = extlink.css
files[] = extlink.test
; Information added by drupal.org packaging script on 2013-07-29
version = "7.x-1.13"
; Information added by Drupal.org packaging script on 2014-07-25
version = "7.x-1.18"
core = "7.x"
project = "extlink"
datestamp = "1375069568"
datestamp = "1406278728"

View File

@@ -1,7 +1,7 @@
<?php
/**
* Implementation of hook_install().
* Implements hook_install().
*/
function extlink_install() {
// Weight needs to be 1 for compatibility with SpamSpan.
@@ -9,9 +9,16 @@ function extlink_install() {
}
/**
* Implementation of hook_uninstall().
* Implements hook_uninstall().
*/
function extlink_uninstall() {
db_query("DELETE FROM {variable} WHERE name LIKE 'extlink_%'");
cache()->deleteTags(array('variables' => TRUE));
cache_clear_all('variables', 'cache');
}
/**
* Delete "extlink_target_value" variable (now uses "extlink_target" directly).
*/
function extlink_update_7101(&$sandbox) {
variable_del('extlink_target_value');
}

View File

@@ -1,20 +1,27 @@
(function ($) {
function extlinkAttach(context) {
Drupal.extlink = Drupal.extlink || {};
Drupal.extlink.attach = function (context, settings) {
if (!settings.hasOwnProperty('extlink')) {
return;
}
// Strip the host name down, removing ports, subdomains, or www.
var pattern = /^(([^\/:]+?\.)*)([^\.:]{4,})((\.[a-z]{1,4})*)(:[0-9]{1,5})?$/;
var host = window.location.host.replace(pattern, '$3$4');
var subdomain = window.location.host.replace(pattern, '$1');
// Determine what subdomains are considered internal.
if (Drupal.settings.extlink.extSubdomains) {
var subdomains = "([^/]*\\.)?";
var subdomains;
if (settings.extlink.extSubdomains) {
subdomains = "([^/]*\\.)?";
}
else if (subdomain == 'www.' || subdomain == '') {
var subdomains = "(www\\.)?";
subdomains = "(www\\.)?";
}
else {
var subdomains = subdomain.replace(".", "\\.");
subdomains = subdomain.replace(".", "\\.");
}
// Build regular expressions that define an internal link.
@@ -22,29 +29,29 @@ function extlinkAttach(context) {
// Extra internal link matching.
var extInclude = false;
if (Drupal.settings.extlink.extInclude) {
extInclude = new RegExp(Drupal.settings.extlink.extInclude.replace(/\\/, '\\'));
if (settings.extlink.extInclude) {
extInclude = new RegExp(settings.extlink.extInclude.replace(/\\/, '\\'), "i");
}
// Extra external link matching.
var extExclude = false;
if (Drupal.settings.extlink.extExclude) {
extExclude = new RegExp(Drupal.settings.extlink.extExclude.replace(/\\/, '\\'));
if (settings.extlink.extExclude) {
extExclude = new RegExp(settings.extlink.extExclude.replace(/\\/, '\\'), "i");
}
// Extra external link CSS selector exclusion.
var extCssExclude = false;
if (Drupal.settings.extlink.extCssExclude) {
extCssExclude = Drupal.settings.extlink.extCssExclude;
if (settings.extlink.extCssExclude) {
extCssExclude = settings.extlink.extCssExclude;
}
// Extra external link CSS selector explicit.
var extCssExplicit = false;
if (Drupal.settings.extlink.extCssExplicit) {
extCssExplicit = Drupal.settings.extlink.extCssExplicit;
if (settings.extlink.extCssExplicit) {
extCssExplicit = settings.extlink.extCssExplicit;
}
// Find all links which are NOT internal and begin with http (as opposed
// Find all links which are NOT internal and begin with http as opposed
// to ftp://, javascript:, etc. other kinds of links.
// When operating on the 'this' variable, the host has been appended to
// all links by the browser, even local ones.
@@ -52,75 +59,103 @@ function extlinkAttach(context) {
// available in jQuery 1.0 (Drupal 5 default).
var external_links = new Array();
var mailto_links = new Array();
$("a:not(." + Drupal.settings.extlink.extClass + ", ." + Drupal.settings.extlink.mailtoClass + "), area:not(." + Drupal.settings.extlink.extClass + ", ." + Drupal.settings.extlink.mailtoClass + ")", context).each(function(el) {
$("a:not(." + settings.extlink.extClass + ", ." + settings.extlink.mailtoClass + "), area:not(." + settings.extlink.extClass + ", ." + settings.extlink.mailtoClass + ")", context).each(function(el) {
try {
var url = this.href.toLowerCase();
if (url.indexOf('http') == 0
&& (!url.match(internal_link) || (extInclude && url.match(extInclude)))
&& !(extExclude && url.match(extExclude))
&& !(extCssExclude && $(this).parents(extCssExclude).length > 0)
&& !(extCssExplicit && $(this).parents(extCssExplicit).length < 1)) {
if (url.indexOf('http') == 0
&& ((!url.match(internal_link) && !(extExclude && url.match(extExclude))) || (extInclude && url.match(extInclude)))
&& !(extCssExclude && $(this).parents(extCssExclude).length > 0)
&& !(extCssExplicit && $(this).parents(extCssExplicit).length < 1)) {
external_links.push(this);
}
// Do not include area tags with begin with mailto: (this prohibits
// icons from being added to image-maps).
else if (this.tagName != 'AREA'
&& url.indexOf('mailto:') == 0
&& !(extCssExclude && $(this).parents(extCssExclude).length > 0)
&& !(extCssExplicit && $(this).parents(extCssExplicit).length < 1)) {
&& url.indexOf('mailto:') == 0
&& !(extCssExclude && $(this).parents(extCssExclude).length > 0)
&& !(extCssExplicit && $(this).parents(extCssExplicit).length < 1)) {
mailto_links.push(this);
}
}
// IE7 throws errors often when dealing with irregular links, such as:
// <a href="node/10"></a> Empty tags.
// <a href="http://user:pass@example.com">example</a> User:pass syntax.
catch(error) {
catch (error) {
return false;
}
});
if (Drupal.settings.extlink.extClass) {
// Apply the "ext" class to all links not containing images.
if (parseFloat($().jquery) < 1.2) {
$(external_links).not('[img]').addClass(Drupal.settings.extlink.extClass).each(function() { if ($(this).css('display') == 'inline') $(this).after('<span class=' + Drupal.settings.extlink.extClass + '></span>'); });
}
else {
$(external_links).not($(external_links).find('img').parents('a')).addClass(Drupal.settings.extlink.extClass).each(function() { if ($(this).css('display') == 'inline') $(this).after('<span class=' + Drupal.settings.extlink.extClass + '></span>'); });
}
if (settings.extlink.extClass) {
Drupal.extlink.applyClassAndSpan(external_links, settings.extlink.extClass);
}
if (Drupal.settings.extlink.mailtoClass) {
// Apply the "mailto" class to all mailto links not containing images.
if (parseFloat($().jquery) < 1.2) {
$(mailto_links).not('[img]').addClass(Drupal.settings.extlink.mailtoClass).each(function() { if ($(this).css('display') == 'inline') $(this).after('<span class=' + Drupal.settings.extlink.mailtoClass + '></span>'); });
}
else {
$(mailto_links).not($(mailto_links).find('img').parents('a')).addClass(Drupal.settings.extlink.mailtoClass).each(function() { if ($(this).css('display') == 'inline') $(this).after('<span class=' + Drupal.settings.extlink.mailtoClass + '></span>'); });
}
if (settings.extlink.mailtoClass) {
Drupal.extlink.applyClassAndSpan(mailto_links, settings.extlink.mailtoClass);
}
if (Drupal.settings.extlink.extTarget) {
if (settings.extlink.extTarget) {
// Apply the target attribute to all links.
$(external_links).attr('target', Drupal.settings.extlink.extTarget);
$(external_links).attr('target', settings.extlink.extTarget);
}
if (Drupal.settings.extlink.extAlert) {
// Add pop-up click-through dialog.
$(external_links).click(function(e) {
return confirm(Drupal.settings.extlink.extAlertText);
});
}
Drupal.extlink = Drupal.extlink || {};
// Work around for Internet Explorer box model problems.
if (($.support && !($.support.boxModel === undefined) && !$.support.boxModel) || ($.browser.msie && parseInt($.browser.version) <= 7)) {
$('span.ext, span.mailto').css('display', 'inline-block');
}
}
// Set up default click function for the external links popup. This should be
// overridden by modules wanting to alter the popup.
Drupal.extlink.popupClickHandler = Drupal.extlink.popupClickHandler || function() {
if (settings.extlink.extAlert) {
return confirm(settings.extlink.extAlertText);
}
}
Drupal.behaviors.extlink = {
attach: function(context){
$(external_links).click(function(e) {
return Drupal.extlink.popupClickHandler(e);
});
};
/**
* Apply a class and a trailing <span> to all links not containing images.
*
* @param links
* An array of DOM elements representing the links.
* @param class_name
* The class to apply to the links.
*/
Drupal.extlink.applyClassAndSpan = function (links, class_name) {
var $links_to_process;
if (Drupal.settings.extlink.extImgClass){
$links_to_process = $(links);
}
else {
var links_with_images = $(links).find('img').parents('a');
$links_to_process = $(links).not(links_with_images);
}
$links_to_process.addClass(class_name);
var i;
var length = $links_to_process.length;
for (i = 0; i < length; i++) {
var $link = $($links_to_process[i]);
if ($link.css('display') == 'inline' || $link.css('display') == 'inline-block') {
if (class_name == Drupal.settings.extlink.mailtoClass) {
$link.append('<span class="' + class_name + '"><span class="element-invisible"> ' + Drupal.settings.extlink.mailtoLabel + '</span></span>');
}
else {
$link.append('<span class="' + class_name + '"><span class="element-invisible"> ' + Drupal.settings.extlink.extLabel + '</span></span>');
}
}
}
};
Drupal.behaviors.extlink = Drupal.behaviors.extlink || {};
Drupal.behaviors.extlink.attach = function (context, settings) {
// Backwards compatibility, for the benefit of modules overriding extlink
// functionality by defining an "extlinkAttach" global function.
if (typeof extlinkAttach === 'function') {
extlinkAttach(context);
}
}
else {
Drupal.extlink.attach(context, settings);
}
};
})(jQuery);

View File

@@ -1,5 +1,7 @@
<?php
/**
* Implements hook_menu().
*/
function extlink_menu() {
$items = array();
$items['admin/config/user-interface/extlink'] = array(
@@ -14,7 +16,7 @@ function extlink_menu() {
}
/**
* Implementation of hook_init().
* Implements hook_page_build().
*/
function extlink_page_build() {
$path = drupal_get_path('module', 'extlink');
@@ -22,6 +24,8 @@ function extlink_page_build() {
drupal_add_js(array('extlink' => array(
'extTarget' => variable_get('extlink_target', 0),
'extClass' => variable_get('extlink_class', 'ext'),
'extLabel' => check_plain(variable_get('extlink_label', t('(link is external)'))),
'extImgClass' => variable_get('extlink_img_class', 0),
'extSubdomains' => variable_get('extlink_subdomains', 1),
'extExclude' => variable_get('extlink_exclude', ''),
'extInclude' => variable_get('extlink_include', ''),
@@ -29,8 +33,9 @@ function extlink_page_build() {
'extCssExplicit' => variable_get('extlink_css_explicit', ''),
'extAlert' => variable_get('extlink_alert', 0),
'extAlertText' => variable_get('extlink_alert_text', 'This link will take you to an external web site. We are not responsible for their content.'),
'mailtoClass' => variable_get('extlink_mailto_class', 'mailto'))), 'setting'
);
'mailtoClass' => variable_get('extlink_mailto_class', 'mailto'),
'mailtoLabel' => check_plain(variable_get('extlink_mailto_label', t('(link sends e-mail)'))),
)), 'setting');
}
function extlink_admin_settings() {
@@ -46,12 +51,20 @@ function extlink_admin_settings() {
$form['extlink_mailto_class'] = array(
'#type' => 'checkbox',
'#title' => t('Place an icon next to mailto links'),
'#title' => t('Place an icon next to mailto links.'),
'#return_value' => 'mailto',
'#default_value' => variable_get('extlink_mailto_class', 'mailto'),
'#description' => t('Places an !icon icon next to mailto links.', array('!icon' => theme('image',array('path' => drupal_get_path('module', 'extlink') . '/mailto.png', 'alt' => t('Email links icon'))))),
);
$form['extlink_img_class'] = array(
'#type' => 'checkbox',
'#title' => t('Place an icon next to image links.'),
'#return_value' => TRUE,
'#default_value' => variable_get('extlink_img_class', FALSE),
'#description' => t('If checked, images wrapped in an anchor tag will be treated as external links.'),
);
$form['extlink_subdomains'] = array(
'#type' => 'checkbox',
'#title' => t('Exclude links with the same primary domain.'),
@@ -61,7 +74,7 @@ function extlink_admin_settings() {
$form['extlink_target'] = array(
'#type' => 'checkbox',
'#title' => t('Open external links in a new window'),
'#title' => t('Open external links in a new window.'),
'#return_value' => '_blank',
'#default_value' => variable_get('extlink_target', 0),
);
@@ -88,16 +101,16 @@ function extlink_admin_settings() {
);
$patterns = array(
'<em>(example\.com)</em> ' . t('Matches example.com.'),
'<em>(example\.com)|(example\.net)</em> ' . t('Multiple patterns can be strung together by using a pipe. Matches example.com OR example.net.'),
'<em>(links/goto/[0-9]+/[0-9]+)</em> ' . t('Matches links that go through the <a href="http://drupal.org/project/links">Links module</a> redirect.'),
'<code>(example\.com)</code> ' . t('Matches example.com.'),
'<code>(example\.com)|(example\.net)</code> ' . t('Multiple patterns can be strung together by using a pipe. Matches example.com OR example.net.'),
'<code>(links/goto/[0-9]+/[0-9]+)</code> ' . t('Matches links that go through the <a href="http://drupal.org/project/links">Links module</a> redirect.'),
);
$wildcards = array(
'<em>.</em> ' . t('Matches any character.'),
'<em>?</em> ' . t('The previous character or set is optional.'),
'<em>\d</em> ' . t('Matches any digit (0-9).'),
'<em>[a-z]</em> ' . t('Brackets may be used to match a custom set of characters. This matches any alphabetic letter.'),
'<code>.</code> ' . t('Matches any character.'),
'<code>?</code> ' . t('The previous character or set is optional.'),
'<code>\d</code> ' . t('Matches any digit (0-9).'),
'<code>[a-z]</code> ' . t('Brackets may be used to match a custom set of characters. This matches any alphabetic letter.'),
);
$form['patterns'] = array(
@@ -112,7 +125,7 @@ function extlink_admin_settings() {
theme('item_list', array('items' => $patterns)) .
t('Common special characters:') .
theme('item_list', array('items' => $wildcards)) .
'<p>' . t('All special characters (<em>^ $ . ? ( ) | * +</em>) must also be escaped with backslashes. Patterns are not case-sensitive. Any <a href="http://www.javascriptkit.com/javatutors/redev2.shtml">pattern supported by JavaScript</a> may be used.') . '</p>',
'<p>' . t('All special characters (!characters) must also be escaped with backslashes. Patterns are not case-sensitive. Any <a href="http://www.javascriptkit.com/javatutors/redev2.shtml">pattern supported by JavaScript</a> may be used.', array('!characters' => '<code>^ $ . ? ( ) | * +</code>')) . '</p>',
);
$form['patterns']['extlink_exclude'] = array(

View File

@@ -1,25 +1,97 @@
<?php
/**
* Administration tests for my module.
*/
class ExtlinkAdministrationTestCase extends DrupalWebTestCase {
/**
* Implements getInfo().
* Base class for External Link tests.
*
* Provides common setup stuff and various helper functions
*/
class ExtlinkBaseWebTestCase extends DrupalWebTestCase {
/**
* User with various administrative permissions.
* @var Drupal user
*/
protected $admin_user;
/**
* Normal visitor with limited permissions
* @var Drupal user;
*/
protected $normal_user;
/**
* Drupal path of the (general) External Links admin page
*/
const EXTLINK_ADMIN_PATH = 'admin/config/user-interface/extlink';
function setUp() {
// Enable any module that you will need in your tests.
parent::setUp('extlink');
// Create a normal user.
$permissions = array(
'access comments', 'post comments', 'skip comment approval',
'access content', 'create page content', 'edit own page content',
);
$this->normal_user = $this->drupalCreateUser($permissions);
// Create an admin user.
$permissions[] = 'administer site configuration';
$permissions[] = 'administer permissions';
$permissions[] = 'administer content types';
$this->admin_user = $this->drupalCreateUser($permissions);
}
protected function getNodeFormValues() {
$edit = array(
'title' => 'node_title ' . $this->randomName(32),
'body[' . LANGUAGE_NONE . '][0][value]' => 'node_body ' . $this->randomName(256) . ' <a href="http://google.com">Google!</a>',
);
return $edit;
}
/**
* Test if External Link is present
*/
protected function assertExternalLinkPresence() {
$elements = $this->xpath('//span[@class="ext"]');
if (count($elements) > 0)
$this->pass('There should be an External Link on the form.', 'External Links');
else
$this->fail('There should be an External Link on the form.', 'External Links');
}
}
class ExtlinkTestCase extends ExtlinkBaseWebTestCase {
public static function getInfo() {
return array (
'name' => t('Administration'),
'description' => t('Administration tests for my module.'),
return array(
'name' => t('General External Links functionality'),
'description' => t('Testing the basic functionality of External Links'),
'group' => t('External Links'),
);
}
public function
}
setUp() {
// Enable any module that you will need in your tests.
parent::setUp();
class ExtlinkAdminTestCase extends ExtlinkBaseWebTestCase {
public static function getInfo() {
return array(
'name' => t('External Links administration functionality'),
'description' => t('Testing of the External Links administration interface and functionality.'),
'group' => t('External Links'),
);
}
/**
* Test access to the admin pages.
*/
function testAdminAccess() {
$this->drupalLogin($this->normal_user);
$this->drupalGet(self::EXTLINK_ADMIN_PATH);
file_put_contents('tmp.simpletest.html', $this->drupalGetContent());
$this->assertText(t('Access denied'), 'Normal users should not be able to access the External Links admin pages', 'External Links');
$this->drupalLogin($this->admin_user);
$this->drupalGet(self::EXTLINK_ADMIN_PATH);
file_put_contents('tmp.simpletest.html', $this->drupalGetContent());
$this->assertNoText(t('Access denied'), 'Admin users should be able to access the External Links admin pages', 'External Links');
}
}
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 B