bregydoc / gtranslate

Google translate API for unlimited and free translations, gtranslate generates the necessary token to use the Google Translate API for free

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tk is computed incorrectly

opennota opened this issue · comments

This code does nothing useful:

token := get(t, ttk)

You can pass any tk token with client=gtx and still get the result. And the token is computed incorrectly anyway. You should have passed the submatch here (matches[1]):

gtranslate/token.go

Lines 119 to 121 in 1bd07f6

matches := regexp.MustCompile(`tkk:\s?'(.+?)'`).FindStringSubmatch(string(body))
if len(matches) > 0 {
v, err := otto.ToValue(matches[0])

Also, otto (unlike goja) incorrectly works with emojis (issue 388), so it will compute an incorrect token every time the text to be translated contains any emoji.