Comments (2)
同样的问题,你怎么解决的?
from base64captcha.
這是 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
當官方修復這一bug前恐怕只能自己 fork 一份來執行上述代碼替換。或者當你在創建任何 driver 前先自行確保屬性值是合法的
from base64captcha.
Related Issues (20)
- 文字验证码,如何设置字的颜色?
- Upgrade: use context to track or control all the flow HOT 1
- Verify method must check the empty id and answer
- go mod 报错问题 go build 报错 HOT 4
- 图片base64如何去掉data:image/png;base64,
- 为啥如果有多个实例的时候,最好调用store.verify HOT 1
- 中文图片显示不出来 HOT 2
- 建议包初始化时,不加载中文字体包
- Captcha对象支持重用吗? HOT 1
- 如何忽略大小写呢
- Verify方法的clear参数, HOT 1
- 通过下面这种方式创建的driverstring 不能修改字体样式,即driver.Fonts不生效 HOT 1
- 特殊值永远成功漏洞 CVE-2023-45292 GO-2023-2386 HOT 2
- 生成中文验证码乱码
- verify bug
- error on line 52
- 如何设置字体大小 HOT 3
- base64Captcha 库没有 SetCustomStore 方法
- mat be use store.Verify()
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from base64captcha.