Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 41e7f75

Browse files
Jaroslaw ZolnowskiSplaktar
Jaroslaw Zolnowski
authored andcommitted
refactor(hooks): suppress the codeql warning regarding replacing only the first occurrence of '>'
1 parent cc7e889 commit 41e7f75

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

‎hooks/after_prepare/010_add_platform_class.js‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,13 @@ function addPlatformBodyTag(indexPath, platform) {
3737
newBodyTag = bodyTag.replace(classAttr, newClassAttr);
3838

3939
} else {
40+
// The bodyTag contains only the first found of `>`, due to the return of the first element of the array from method
41+
// (findBodyTag)[https://github.com/xlts-dev/angularjs-ionic-v1/blob/c553c973d85142e66f119aed2fe3db83775f5f2b/hooks
42+
// /after_prepare/010_add_platform_class.js#L57]. Therefore, we should replace only one tag.
43+
// Fix https://github.com/xlts-dev/angularjs-ionic-v1/security/code-scanning/1 CodeQL warning
44+
var closingBracketIdx = bodyTag.indexOf('>');
4045
// add class attribute to the body tag
41-
newBodyTag = bodyTag.replace('>',' + platformClass + ' ' + cordovaClass + '">');
46+
newBodyTag = bodyTag.slice(0,closingBracketIdx)+' class="' + platformClass + ' ' + cordovaClass + '"'+bodyTag.slice(closingBracketIdx);
4247
}
4348

4449
html = html.replace(bodyTag, newBodyTag);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /