Skip to content

Commit

Permalink
Merge branch 'version-1.4.x' into NODE-2449-run-ride-on-any-environment
Browse files Browse the repository at this point in the history
  • Loading branch information
phearnot authored Oct 12, 2023
2 parents 3c3475e + 7a7bae1 commit 9b42f69
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ object Decompiler {
}
}

val MatchRef = """(\$match\d*)""".r
private val MatchRef = """(\$match\d*)""".r
private val EscapingSymbols = "[\\\\\"]".r

private[lang] def expr(e: Coeval[EXPR], ctx: DecompilerContext, braces: BlockBraces, firstLinePolicy: FirstLinePolicy): Coeval[String] = {
def checkBrackets(expr: EXPR) = expr match {
Expand Down Expand Up @@ -161,8 +162,8 @@ object Decompiler {
case Terms.TRUE => pureOut("true", i)
case Terms.FALSE => pureOut("false", i)
case Terms.CONST_BOOLEAN(b) => pureOut(b.toString.toLowerCase(), i)
case Terms.CONST_LONG(t) => pureOut(t.toLong.toString, i)
case Terms.CONST_STRING(s) => pureOut("\"" ++ s ++ "\"", i)
case Terms.CONST_LONG(t) => pureOut(t.toString, i)
case Terms.CONST_STRING(s) => pureOut("\"" ++ EscapingSymbols.replaceAllIn(s, "\\\\$0") ++ "\"", i)
case Terms.CONST_BYTESTR(bs) =>
pureOut(
if (bs.size <= 128) { "base58'" ++ bs.toString ++ "'" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DecompilerTest extends PropSpec {
val decompilerContextV4 = getTestContext(V4).decompilerContext

private def assertDecompile(script: String, decompiled: String, version: StdLibVersion): Assertion = {
val expr = TestCompiler(version).compileExpression(script.stripMargin).expr.asInstanceOf[EXPR]
val expr = TestCompiler(version).compileExpression(script.stripMargin).expr
val result = Decompiler(expr, getDecompilerContext(version, Expression))
result shouldBe decompiled.stripMargin.trim
}
Expand Down Expand Up @@ -1116,4 +1116,14 @@ class DecompilerTest extends PropSpec {
.filter(_ >= V6)
.foreach(assertDecompile(script, decompiledV6, _))
}

property("escaping characters in string") {
val script =
s"""
|let a = "aaa\\"qqq\\"aaa"
|let b = "aaa\\\\qqq\\\\aaa"
|true
"""
assertDecompile(script, script, V6)
}
}
20 changes: 12 additions & 8 deletions node/src/package/debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@ if [ "$1" = configure ]; then
adduser $quiet ${{app_name}} ${{app_name}}
fi

# ensure home directory ownership
mkdir -p /var/lib/${{app_name}}
chown -R ${{app_name}}:${{app_name}} /var/lib/${{app_name}}
chown -R ${{app_name}}:${{app_name}} /usr/share/${{app_name}}
if [ ! -d /var/lib/${{app_name}} ] ; then
# ensure home directory ownership
mkdir -p /var/lib/${{app_name}}
chown -R ${{app_name}}:${{app_name}} /var/lib/${{app_name}}
fi

# nicer log directory permissions
mkdir -p /var/log/${{app_name}}
chmod 770 /var/log/${{app_name}}
chown root:${{app_name}} /var/log/${{app_name}}
if [ ! -d /var/log/${{app_name}} ] ; then
# nicer log directory permissions
mkdir -p /var/log/${{app_name}}
chmod 770 /var/log/${{app_name}}
chown root:${{app_name}} /var/log/${{app_name}}
fi
chown -R ${{app_name}}:${{app_name}} /usr/share/${{app_name}}

if [ ! -f "$config_file" ]; then
echo Creating default config file ...
Expand Down

0 comments on commit 9b42f69

Please sign in to comment.