Skip to content

Commit 958a7ae

Browse files
committed
feat: Enforce a proper application location
Close #1301, Close #1298
1 parent 7c6b4ab commit 958a7ae

File tree

4 files changed

+71
-7
lines changed

4 files changed

+71
-7
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"ajv": "^5.0.4-beta.0",
3232
"ajv-keywords": "^2.0.1-beta.2",
3333
"archiver": "^1.3.0",
34-
"aws-sdk": "^2.32.0",
34+
"aws-sdk": "^2.33.0",
3535
"bluebird-lst": "^1.0.2",
3636
"chalk": "^1.1.3",
3737
"chromium-pickle-js": "^0.2.0",
@@ -48,7 +48,7 @@
4848
"mime": "^1.3.4",
4949
"minimatch": "^3.0.3",
5050
"node-emoji": "^1.5.1",
51-
"node-forge": "^0.7.0",
51+
"node-forge": "^0.7.1",
5252
"normalize-package-data": "^2.3.6",
5353
"parse-color": "^1.0.0",
5454
"plist": "^2.0.1",
@@ -63,7 +63,7 @@
6363
"yargs": "^7.0.2"
6464
},
6565
"devDependencies": {
66-
"@types/electron": "^1.4.34",
66+
"@types/electron": "^1.4.35",
6767
"@types/ini": "^1.3.29",
6868
"@types/jest": "^19.2.2",
6969
"@types/js-yaml": "^3.5.29",
@@ -89,7 +89,7 @@
8989
"source-map-support": "^0.4.14",
9090
"ts-babel": "^3.0.0",
9191
"tslint": "^4.5.1",
92-
"typescript": "^2.2.1",
92+
"typescript": "^2.2.2",
9393
"typescript-json-schema": "0.10.0",
9494
"whitespace": "^2.1.0",
9595
"xml2js": "^0.4.17"

packages/electron-builder/templates/nsis/boringInstaller.nsh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,23 @@
2727
!endif
2828

2929
!ifdef allowToChangeInstallationDirectory
30+
!include StrContains.nsh
31+
3032
!insertmacro MUI_PAGE_DIRECTORY
33+
34+
# pageDirectory leave doesn't work (it seems because $INSTDIR is set after custom leave function)
35+
# so, we yse instfiles pre
36+
!define MUI_PAGE_CUSTOMFUNCTION_PRE instFilesPre
37+
38+
# Sanitize the MUI_PAGE_DIRECTORY result to make sure it has a application name sub-folder
39+
Function instFilesPre
40+
${If} ${FileExists} "$INSTDIR\*"
41+
${StrContains} $0 "${APP_FILENAME}" $INSTDIR
42+
${If} $0 == ""
43+
StrCpy $INSTDIR "$INSTDIR\${APP_FILENAME}"
44+
${endIf}
45+
${endIf}
46+
FunctionEnd
3147
!endif
3248
!insertmacro MUI_PAGE_INSTFILES
3349
!insertmacro MUI_PAGE_FINISH
@@ -49,7 +65,7 @@
4965
# special return value for outer instance so it knows we did not have admin rights
5066
SetErrorLevel 0x666666
5167
Quit
52-
${EndIf}
68+
${endIf}
5369

5470
!ifndef MULTIUSER_INIT_TEXT_ADMINREQUIRED
5571
!define MULTIUSER_INIT_TEXT_ADMINREQUIRED "$(^Caption) requires administrator privileges."
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
; StrContains
2+
; This function does a case sensitive searches for an occurrence of a substring in a string.
3+
; It returns the substring if it is found.
4+
; Otherwise it returns null("").
5+
; Written by kenglish_hi
6+
; Adapted from StrReplace written by dandaman32
7+
8+
9+
Var STR_HAYSTACK
10+
Var STR_NEEDLE
11+
Var STR_CONTAINS_VAR_1
12+
Var STR_CONTAINS_VAR_2
13+
Var STR_CONTAINS_VAR_3
14+
Var STR_CONTAINS_VAR_4
15+
Var STR_RETURN_VAR
16+
17+
Function StrContains
18+
Exch $STR_NEEDLE
19+
Exch 1
20+
Exch $STR_HAYSTACK
21+
; Uncomment to debug
22+
;MessageBox MB_OK 'STR_NEEDLE = $STR_NEEDLE STR_HAYSTACK = $STR_HAYSTACK '
23+
StrCpy $STR_RETURN_VAR ""
24+
StrCpy $STR_CONTAINS_VAR_1 -1
25+
StrLen $STR_CONTAINS_VAR_2 $STR_NEEDLE
26+
StrLen $STR_CONTAINS_VAR_4 $STR_HAYSTACK
27+
loop:
28+
IntOp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_1 + 1
29+
StrCpy $STR_CONTAINS_VAR_3 $STR_HAYSTACK $STR_CONTAINS_VAR_2 $STR_CONTAINS_VAR_1
30+
StrCmp $STR_CONTAINS_VAR_3 $STR_NEEDLE found
31+
StrCmp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_4 done
32+
Goto loop
33+
found:
34+
StrCpy $STR_RETURN_VAR $STR_NEEDLE
35+
Goto done
36+
done:
37+
Pop $STR_NEEDLE ;Prevent "invalid opcode" errors and keep the
38+
Exch $STR_RETURN_VAR
39+
FunctionEnd
40+
41+
!macro _StrContainsConstructor OUT NEEDLE HAYSTACK
42+
Push `${HAYSTACK}`
43+
Push `${NEEDLE}`
44+
Call StrContains
45+
Pop `${OUT}`
46+
!macroend
47+
48+
!define StrContains '!insertmacro "_StrContainsConstructor"'

yarn.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3217,8 +3217,8 @@ typescript-json-schema@0.10.0:
32173217
yargs "^6.6.0"
32183218

32193219
typescript@^2.2.1:
3220-
version "2.2.1"
3221-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.2.1.tgz#4862b662b988a4c8ff691cc7969622d24db76ae9"
3220+
version "2.2.2"
3221+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.2.2.tgz#606022508479b55ffa368b58fee963a03dfd7b0c"
32223222

32233223
typescript@~2.1.5:
32243224
version "2.1.6"

0 commit comments

Comments
 (0)