Skip to content

Commit

Permalink
fix(codeql): fixed codeql findings where applicable
Browse files Browse the repository at this point in the history
This PR fixes the CodeQl findings as of #2354 (checks) from #2354

2 medium findings are false positives as codeql did not recognize the "preserveHTML" logic correctly.
  • Loading branch information
lubber-de authored May 29, 2022
1 parent 054fffa commit 7444956
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/definitions/behaviors/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ $.api = $.fn.api = function(parameters) {

// context used for state
$context = (settings.stateContext)
? $(settings.stateContext)
? ([window,document].indexOf(settings.stateContext) < 0 ? $(document).find(settings.stateContext) : $(settings.stateContext))
: $module,

// request details
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/behaviors/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ $.fn.form = function(parameters) {
if(settings.errorFocus && ignoreCallbacks !== true) {
var focusElement, hasTabIndex = true;
if (typeof settings.errorFocus === 'string') {
focusElement = $(settings.errorFocus);
focusElement = $(document).find(settings.errorFocus);
hasTabIndex = focusElement.is('[tabindex]');
// to be able to focus/scroll into non input elements we need a tabindex
if (!hasTabIndex) {
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/behaviors/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ $.fn.state = function(parameters) {

// bind events with delegated events
if(settings.context && moduleSelector !== '') {
$(settings.context)
([window,document].indexOf(settings.context) < 0 ? $(document).find(settings.context) : $(settings.context))
.on(moduleSelector, 'mouseenter' + eventNamespace, module.change.text)
.on(moduleSelector, 'mouseleave' + eventNamespace, module.reset.text)
.on(moduleSelector, 'click' + eventNamespace, module.toggle.state)
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/behaviors/visibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ $.fn.visibility = function(parameters) {
$window = $(window),

$module = $(this),
$context = $(settings.context),
$context = [window,document].indexOf(settings.context) < 0 ? $(document).find(settings.context) : $(settings.context),

$placeholder,

Expand Down
2 changes: 1 addition & 1 deletion src/definitions/modules/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ $.fn.calendar = function(parameters) {
return null;
}
if (!(selector instanceof $)) {
selector = $(selector).first();
selector = $(document).find(selector).first();
}
//assume range related calendars are using the same namespace
return selector.data(moduleNamespace);
Expand Down
4 changes: 2 additions & 2 deletions src/definitions/modules/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ $.fn.dropdown = function(parameters) {
moduleNamespace = 'module-' + namespace,

$module = $(this),
$context = $(settings.context),
$context = [window,document].indexOf(settings.context) < 0 ? $(document).find(settings.context) : $(settings.context),
$text = $module.find(selector.text),
$search = $module.find(selector.search),
$sizer = $module.find(selector.sizer),
Expand Down Expand Up @@ -2917,7 +2917,7 @@ $.fn.dropdown = function(parameters) {
$('<option/>')
.prop('value', escapedValue)
.addClass(className.addition)
.html(value)
.text(value)
.appendTo($input)
;
module.verbose('Adding user addition as an <option>', value);
Expand Down
4 changes: 2 additions & 2 deletions src/definitions/modules/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ $.fn.modal = function(parameters) {
moduleNamespace = 'module-' + namespace,

$module = $(this),
$context = $(settings.context),
$context = [window,document].indexOf(settings.context) < 0 ? $(document).find(settings.context) : $(settings.context),
$closeIcon = $module.find(selector.closeIcon),
$inputs,

Expand Down Expand Up @@ -124,7 +124,7 @@ $.fn.modal = function(parameters) {
click = el[fields.click] && $.isFunction(el[fields.click]) ? el[fields.click] : function () {};
$actions.append($('<button/>', {
html: icon + text,
'aria-label': $('<div>'+(el[fields.text] || el[fields.icon] || '')+'</div>').text(),
'aria-label': (el[fields.text] || el[fields.icon] || '').replace(/<[^>]+(>|$)/g,''),
class: className.button + ' ' + cls,
click: function () {
var button = $(this);
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/modules/nag.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ $.fn.nag = function(parameters) {
$module = $(this),

$context = (settings.context)
? $(settings.context)
? ([window,document].indexOf(settings.context) < 0 ? $(document).find(settings.context) : $(settings.context))
: $('body'),

element = this,
Expand Down
18 changes: 9 additions & 9 deletions src/definitions/modules/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ $.fn.popup = function(parameters) {
moduleNamespace = 'module-' + namespace,

$module = $(this),
$context = $(settings.context),
$scrollContext = $(settings.scrollContext),
$boundary = $(settings.boundary),
$context = [window,document].indexOf(settings.context) < 0 ? $(document).find(settings.context) : $(settings.context),
$scrollContext = [window,document].indexOf(settings.scrollContext) < 0 ? $(document).find(settings.scrollContext) : $(settings.scrollContext),
$boundary = [window,document].indexOf(settings.boundary) < 0 ? $(document).find(settings.boundary) : $(settings.boundary),
$target = (settings.target)
? $(settings.target)
? ([window,document].indexOf(settings.target) < 0 ? $(document).find(settings.target) : $(settings.target))
: $module,

$popup,
Expand Down Expand Up @@ -121,8 +121,8 @@ $.fn.popup = function(parameters) {
},

refresh: function() {
if(settings.popup) {
$popup = $(settings.popup).eq(0);
if(settings.popup && typeof settings.popup === 'string') {
$popup = $(document).find(settings.popup).eq(0);
}
else {
if(settings.inline) {
Expand Down Expand Up @@ -286,8 +286,8 @@ $.fn.popup = function(parameters) {
}
settings.onCreate.call($popup, element);
}
else if(settings.popup) {
$(settings.popup).data(metadata.activator, $module);
else if(settings.popup && typeof settings.popup === 'string') {
$(document).find(settings.popup).data(metadata.activator, $module);
module.verbose('Used popup specified in settings');
module.refresh();
if(settings.hoverable) {
Expand Down Expand Up @@ -368,7 +368,7 @@ $.fn.popup = function(parameters) {
},

hideAll: function() {
$(selector.popup)
$(document).find(selector.popup)
.filter('.' + className.popupVisible)
.each(function() {
$(this)
Expand Down
4 changes: 2 additions & 2 deletions src/definitions/modules/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ $.fn.sidebar = function(parameters) {
moduleNamespace = 'module-' + namespace,

$module = $(this),
$context = $(settings.context),
$context = [window,document].indexOf(settings.context) < 0 ? $(document).find(settings.context) : $(settings.context),

$sidebars = $module.children(selector.sidebar),
$fixed = $context.children(selector.fixed),
Expand Down Expand Up @@ -294,7 +294,7 @@ $.fn.sidebar = function(parameters) {

refresh: function() {
module.verbose('Refreshing selector cache');
$context = $(settings.context);
$context = [window,document].indexOf(settings.context) < 0 ? $(document).find(settings.context) : $(settings.context);
$sidebars = $context.children(selector.sidebar);
$pusher = $context.children(selector.pusher);
$fixed = $context.children(selector.fixed);
Expand Down
6 changes: 3 additions & 3 deletions src/definitions/modules/sticky.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ $.fn.sticky = function(parameters) {

$module = $(this),
$window = $(window),
$scroll = $(settings.scrollContext),
$scroll = [window,document].indexOf(settings.scrollContext) < 0 ? $(document).find(settings.scrollContext) : $(settings.scrollContext),
$container,
$context,

Expand Down Expand Up @@ -139,7 +139,7 @@ $.fn.sticky = function(parameters) {

determineContainer: function() {
if(settings.container) {
$container = $(settings.container);
$container = [window,document].indexOf(settings.container) < 0 ? $(document).find(settings.container) : $(settings.container);
}
else {
$container = $module.offsetParent();
Expand All @@ -148,7 +148,7 @@ $.fn.sticky = function(parameters) {

determineContext: function() {
if(settings.context) {
$context = $(settings.context);
$context = [window,document].indexOf(settings.context) < 0 ? $(document).find(settings.context) : $(settings.context);
}
else {
$context = $container;
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/modules/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ $.fn.tab = function(parameters) {
module.verbose('Determined parent element for creating context', $context);
}
else if(settings.context) {
$context = $(settings.context);
$context = [window,document].indexOf(settings.context) < 0 ? $(document).find(settings.context) : $(settings.context);
module.verbose('Using selector for tab context', settings.context, $context);
}
else {
Expand Down
4 changes: 2 additions & 2 deletions src/definitions/modules/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ $.fn.toast = function(parameters) {
$animationObject,
$close,
$context = (settings.context)
? $(settings.context)
? ([window,document].indexOf(settings.context) < 0 ? $(document).find(settings.context) : $(settings.context))
: $('body'),

isToastComponent = $module.hasClass('toast') || $module.hasClass('message') || $module.hasClass('card'),
Expand Down Expand Up @@ -246,7 +246,7 @@ $.fn.toast = function(parameters) {
click = el[fields.click] && $.isFunction(el[fields.click]) ? el[fields.click] : function () {};
$actions.append($('<button/>', {
html: icon + text,
'aria-label': $('<div>'+(el[fields.text] || el[fields.icon] || '')+'</div>').text(),
'aria-label': (el[fields.text] || el[fields.icon] || '').replace(/<[^>]+(>|$)/g,''),
class: className.button + ' ' + cls,
click: function () {
var button = $(this);
Expand Down
4 changes: 2 additions & 2 deletions tasks/build/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ function buildCSS(src, type, config, opts, callback) {
}

if (globs.individuals !== undefined && typeof src === 'string') {
const individuals = config.globs.individuals.replace('{','');
const components = config.globs.components.replace('}',',').concat(individuals);
const individuals = config.globs.individuals.replace(/\{/g,'');
const components = config.globs.components.replace(/\}/g,',').concat(individuals);

src = config.paths.source.definitions + '/**/' + components + '.less';
}
Expand Down
4 changes: 2 additions & 2 deletions tasks/build/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ function buildJS(src, type, config, callback) {
}

if (globs.individuals !== undefined && typeof src === 'string') {
const individuals = config.globs.individuals.replace('{','');
const components = config.globs.components.replace('}',',').concat(individuals);
const individuals = config.globs.individuals.replace(/\{/g,'');
const components = config.globs.components.replace(/\}/g,',').concat(individuals);

src = config.paths.source.definitions + '/**/' + components + (config.globs.ignored || '') + '.js';
}
Expand Down
6 changes: 3 additions & 3 deletions test/coverage/PhantomJS 1.9.2 (Linux)/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
margin-left: 0.5em;
}
div.coverage-summary .yui3-datatable-sort-indicator {
background: url("http://yui.yahooapis.com/3.6.0/build/datatable-sort/assets/skins/sam/sort-arrow-sprite.png") no-repeat scroll 0 0 transparent;
background: url("//yui.yahooapis.com/3.6.0/build/datatable-sort/assets/skins/sam/sort-arrow-sprite.png") no-repeat scroll 0 0 transparent;
}
div.coverage-summary .yui3-datatable-sorted .yui3-datatable-sort-indicator {
background-position: 0 -20px;
Expand Down Expand Up @@ -219,12 +219,12 @@ <h2>
</div>
</div>
<div class="footer">
<div class="meta">Generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Mon Oct 14 2013 01:28:11 GMT-0400 (EDT)</div>
<div class="meta">Generated by <a href="//istanbul-js.org/" target="_blank">istanbul</a> at Mon Oct 14 2013 01:28:11 GMT-0400 (EDT)</div>
</div>

<script src="prettify.js"></script>

<script src="http://yui.yahooapis.com/3.6.0/build/yui/yui-min.js"></script>
<script src="//yui.yahooapis.com/3.6.0/build/yui/yui-min.js"></script>
<script>

YUI().use('datatable', function (Y) {
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/jasmine-jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
}

jasmine.StyleFixtures.prototype.createStyle_ = function (html) {
var styleText = $('<div></div>').html(html).text()
var styleText = html.replace(/<[^>]+(>|$)/g,'')
, style = $('<style>' + styleText + '</style>')

this.fixturesNodes_.push(style)
Expand Down

0 comments on commit 7444956

Please sign in to comment.