Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -26,7 +26,8 @@ func GetProductPricingListHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
log.Printf("[ProductPricing] trace=%s start user=%s id=%d", traceID, claims.Username, claims.ID)
|
||||
|
||||
ctx, cancel := context.WithTimeout(r.Context(), 180*time.Second)
|
||||
// Cloudflare upstream timeout is lower than 180s; fail fast and return API 504 instead of CDN 524.
|
||||
ctx, cancel := context.WithTimeout(r.Context(), 110*time.Second)
|
||||
defer cancel()
|
||||
|
||||
limit := 500
|
||||
|
||||
@@ -59,6 +59,7 @@ var (
|
||||
reScriptLabelProp = regexp.MustCompile(`\blabel\s*:\s*['"]([^'"]{2,180})['"]`)
|
||||
reScriptUIProp = regexp.MustCompile(`\b(?:label|message|title|placeholder|hint)\s*:\s*['"]([^'"]{2,180})['"]`)
|
||||
reTemplateDynamic = regexp.MustCompile(`[{][{]|[}][}]`)
|
||||
reCodeLikeText = regexp.MustCompile(`(?i)(\bconst\b|\blet\b|\bvar\b|\breturn\b|\bfunction\b|=>|\|\||&&|\?\?|//|/\*|\*/|\.trim\(|\.replace\(|\.map\(|\.filter\()`)
|
||||
)
|
||||
|
||||
var translationNoiseTokens = map[string]struct{}{
|
||||
@@ -1800,9 +1801,22 @@ func isCandidateText(s string) bool {
|
||||
if strings.Contains(s, "/api/") {
|
||||
return false
|
||||
}
|
||||
if reCodeLikeText.MatchString(s) {
|
||||
return false
|
||||
}
|
||||
if strings.ContainsAny(s, "{}[];`") {
|
||||
return false
|
||||
}
|
||||
symbolCount := 0
|
||||
for _, r := range s {
|
||||
switch r {
|
||||
case '(', ')', '=', ':', '/', '\\', '|', '&', '*', '<', '>', '_':
|
||||
symbolCount++
|
||||
}
|
||||
}
|
||||
if symbolCount >= 4 {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user