Skip to content
New issue

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

capt.SetRangCheckTextLen 判断条件与变量名存在误导 #2

Closed
strive1216 opened this issue Jun 6, 2022 · 2 comments
Closed

Comments

@strive1216
Copy link

// SetRangCheckTextLen is a function
/**
 * @Description: 设置随机验证文本长度
 * @receiver cc
 * @param val
 */
func (cc *Captcha) SetRangCheckTextLen(val RangeVal) {
	// 检测验证文本范围最大值是否小于随机字符串的最小范围
	if cc.config.rangCheckTextLen.Max > cc.config.rangTextLen.Min {
		panic(fmt.Errorf("CaptchaConfig Error: RangCheckTextLen.max must be less than or equal to RangTextLen.min"))
	}

	cc.config.rangCheckTextLen = val
}

不应该是
if cc.config.rangCheckTextLen.Max < cc.config.rangTextLen.Min {
}

@strive1216
Copy link
Author

这将导致 随机长度无法随机

func (cc *Captcha) GenerateWithSize(imageSize Size, thumbnailSize Size) (map[int]CharDot, string, string, string, error) {
	err := cc.checkConfig()
	length := RandInt(cc.config.rangTextLen.Min, cc.config.rangTextLen.Max)
...........
}

@strive1216
Copy link
Author

不好意思看错 rang CheckTextLen 和 rangTextLen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant