MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / showVerifyCodesForm

Method showVerifyCodesForm

internal/waf/captcha_validator.go:206–344  ·  view source on GitHub ↗
(actionConfig *CaptchaAction, req requests.Request, writer http.ResponseWriter)

Source from the content-addressed store, hash-verified

204}
205
206func (this *CaptchaValidator) showVerifyCodesForm(actionConfig *CaptchaAction, req requests.Request, writer http.ResponseWriter) {
207 // show captcha
208 var countLetters = 6
209 if actionConfig.CountLetters > 0 && actionConfig.CountLetters <= 10 {
210 countLetters = int(actionConfig.CountLetters)
211 }
212 var captchaId = captchaGenerator.NewCaptcha(countLetters)
213
214 var lang = actionConfig.Lang
215 if len(lang) == 0 {
216 var acceptLanguage = req.WAFRaw().Header.Get("Accept-Language")
217 if len(acceptLanguage) > 0 {
218 langIndex := strings.Index(acceptLanguage, ",")
219 if langIndex > 0 {
220 lang = acceptLanguage[:langIndex]
221 }
222 }
223 }
224 if len(lang) == 0 {
225 lang = "en-US"
226 }
227
228 var msgTitle string
229 var msgPrompt string
230 var msgButtonTitle string
231 var msgRequestId string
232 var msgPlaceholder string
233
234 switch lang {
235 case "en-US":
236 msgTitle = "Verify Yourself"
237 msgPrompt = "Input verify code above:"
238 msgButtonTitle = "Verify Yourself"
239 msgRequestId = "Request ID"
240 msgPlaceholder = ""
241 case "zh-CN":
242 msgTitle = "身份验证"
243 msgPrompt = "请输入上面的验证码"
244 msgButtonTitle = "提交验证"
245 msgRequestId = "请求ID"
246 msgPlaceholder = "点此输入"
247 case "zh-TW":
248 msgTitle = "身份驗證"
249 msgPrompt = "請輸入上面的驗證碼"
250 msgButtonTitle = "提交驗證"
251 msgRequestId = "請求ID"
252 msgPlaceholder = "點此輸入"
253 default:
254 msgTitle = "Verify Yourself"
255 msgPrompt = "Input verify code above:"
256 msgButtonTitle = "Verify Yourself"
257 msgRequestId = "Request ID"
258 }
259
260 var msgCss = ""
261 var requestIdBox = `<address>` + msgRequestId + `: ` + req.Format("${requestId}") + `</address>`
262 var msgFooter = ""
263

Callers 1

showMethod · 0.95

Calls 10

NewCaptchaMethod · 0.80
WAFRawMethod · 0.65
FormatMethod · 0.65
WriteHeaderMethod · 0.65
WriteMethod · 0.65
GetMethod · 0.45
StringMethod · 0.45
HeaderMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected