We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
captcha.go,高度参数会导致异常,直接painc了并没有返回error,我觉得应该验证下或者返回error
The text was updated successfully, but these errors were encountered:
同样的问题,你怎么解决的?
Sorry, something went wrong.
這是 rand.Intn 因爲參數 <=0 而執行了 painc。我搜索了下 base64Captcha 中大量代碼都調用了 rand.Intn。所以會有很多不確定的情況導致 rand.Intn 執行 painc。(例如在創建 DriverString 是 Height 設置<16。或者在創建 DriverDigit 時 Height 設置 <7,...) 每種不同的 Driver 要求的屬性合法值都不一樣但創建 Driver 並沒有驗證有效屬性並爲錯誤屬性返回 error。這對正確調用 base64Captcha 造成了很大的負擔
鑑於 rand.Intn 被調用太頻繁,要去爲每個 Driver 驗證參數應該會相當繁瑣。本喵的建議是在源碼中寫一個 randIntn 函數
func randIntn(n int) int{ if n <= 0 { return 0 } return rand.Intn(n) }
然後將源碼中的所有 rand.Intn( 替換爲 randIntn( 這樣當 Driver 某些參數不當時就不會引發 painc
rand.Intn(
randIntn(
當官方修復這一bug前恐怕只能自己 fork 一份來執行上述代碼替換。或者當你在創建任何 driver 前先自行確保屬性值是合法的
No branches or pull requests
captcha.go,高度参数会导致异常,直接painc了并没有返回error,我觉得应该验证下或者返回error
The text was updated successfully, but these errors were encountered: