+
Skip to content
This repository was archived by the owner on Sep 28, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion internal/unbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ type (
}
)

var matchAllNonAlphaNumeric = regexp.MustCompile(`[^a-zA-Z0-9]+`)
// Regex translation:
// \pL - Unicode group for letters, meaning all letters.
// \d - Digits
// Summary, match anything that is not a unicode letter, number, hyphen or underscore.
// This is to ensure that our path names are not "bonkers".
var matchAllNonAlphaNumeric = regexp.MustCompile(`[^\pL\d_-]+`)

// Unbuild exports measures, dimensions, variables, connections, objects and a config file from an app into the file system
func Unbuild(ctx context.Context, doc *enigma.Doc, global *enigma.Global, rootFolder string) {
Expand Down
28 changes: 28 additions & 0 deletions internal/unbuilder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,31 @@ import (
func TestBuildName(t *testing.T) {
fmt.Println(buildEntityFilename("wefwef", "mastesrobject", "table", "'='Halleluljah moment'"))
}

func TestUnbuildRegex(t *testing.T) {
// Inline function to avoid scope pollution
find := func(s string) []string {
return matchAllNonAlphaNumeric.FindAllString(s, -1)
}
pass := []string{
"объект", "αντικείμενο", "חפץ",
"対象", "object", "åbjäkt", "æble",
"___sys", "αντικείμενο19", "hell-here",
"1982", "аяАЯЁё",
}
fail := []string{
"@object", "$erver", "\"hello\"",
"p:;", "~som", "|other", "=thing",
"hello there",
}
for _, s := range pass {
if found := find(s); len(found) != 0 {
t.Errorf("%s should not match the regex but found %v", s, found)
}
}
for _, s := range fail {
if found := find(s); len(found) == 0 {
t.Errorf("%s should match the regex", s)
}
}
}
2 changes: 1 addition & 1 deletion test/golden/TestTrafficFlag_script_get_--traffic.golden
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
--> {"jsonrpc":"2.0","delta":false,"method":"GetActiveDoc","handle":-1,"id":1,"params":[]}
<-- {"jsonrpc":"2.0","id":1,"error":{"code":1007,"parameter":"No active document","message":"App invalid"}}
--> {"jsonrpc":"2.0","delta":false,"method":"OpenDoc","handle":-1,"id":2,"params":["/apps/TestTrafficFlag.qvf","","","",false]}
<-- {"jsonrpc":"2.0","id":2,"result":{"qReturn":{"qType":"Doc","qHandle":1,"qGenericId":"/apps/TestTrafficFlag.qvf"}},"change":[1]}
<-- {"jsonrpc":"2.0","id":2,"result":{"qReturn":{"qType":"Doc","qHandle":1,"qGenericId":"/apps/TestTrafficFlag.qvf"}},"change":[1],"warnings":[1]}
--> {"jsonrpc":"2.0","delta":false,"method":"GetScript","handle":1,"id":3,"params":[]}
<-- {"jsonrpc":"2.0","id":3,"result":{"qScript":"///$tab Main\r\nSET ThousandSep=',';\r\nSET DecimalSep='.';\r\nSET MoneyThousandSep=',';\r\nSET MoneyDecimalSep='.';\r\nSET MoneyFormat='$ ###0.00;-$ ###0.00';\r\nSET TimeFormat='h:mm:ss TT';\r\nSET DateFormat='M/D/YYYY';\r\nSET TimestampFormat='M/D/YYYY h:mm:ss[.fff] TT';\r\nSET FirstWeekDay=6;\r\nSET BrokenWeeks=1;\r\nSET ReferenceDay=0;\r\nSET FirstMonthOfYear=1;\r\nSET CollationLocale='en-US';\r\nSET CreateSearchIndexOnReload=1;\r\nSET MonthNames='Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec';\r\nSET LongMonthNames='January;February;March;April;May;June;July;August;September;October;November;December';\r\nSET DayNames='Mon;Tue;Wed;Thu;Fri;Sat;Sun';\r\nSET LongDayNames='Monday;Tuesday;Wednesday;Thursday;Friday;Saturday;Sunday';\r\nSET NumericalAbbreviation='3:k;6:M;9:G;12:T;15:P;18:E;21:Z;24:Y;-3:m;-6:μ;-9:n;-12:p;-15:f;-18:a;-21:z;-24:y';\r\n"}}
///$tab Main
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载