11 Commits
Author SHA1 Message Date
zavage 9f8a295a4f Merge pull request 'fix: limit the prompt template to 1,000 characters' (#12) from fix/template-length-limit into develop
Reviewed-on: https://git.zavage.net/Zavage-Software/search-with-chatgpt-powered-by-openai-extension/pulls/12
2026-10-18 02:26:43 -06:00
zavage 5a12663c92 Merge pull request 'refactor: remove the unused URL shortener' (#11) from refactor/remove-unused-shortener into develop
Reviewed-on: https://git.zavage.net/Zavage-Software/search-with-chatgpt-powered-by-openai-extension/pulls/11
2026-10-18 02:26:37 -06:00
golemandClaude Opus 5.5 269e721fe8 fix: limit the prompt template to 1,000 characters
storage.sync rejects any item over 8192 bytes, and the options page
writes every field in one set(). An oversized template therefore made
every later save fail, including changes to unrelated settings, with
only a brief "Could not save settings".

Cap the template at 1,000 UTF-16 units: maxlength on the input, and
mergeSettings falls back to the default for a longer stored value, as it
does for other out-of-range settings. Even a template of pasted control
characters (six bytes each once JSON-escaped) stays under the quota; a
test pins that arithmetic and another ties the HTML maxlength to the
constant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 02:23:03 -06:00
golemandClaude Opus 5.5 cc68fe98b5 refactor: remove the unused URL shortener
buildChatGptUrl and its fitToBudget helpers have had no production
caller since prepareAction took over routing; the 2026-10-05 plan kept
them only for existing tests until then. They also shortened silently,
against the ask-before-shortening rule, so they were a trap to reuse.

Port the tests that guard live code onto applyTemplate and
serializePrompt, including the $&, $`, $' and $$ regressions (checked to
fail against the string-replacement form), and cover prepareAction's
whole-word cut, which nothing tested before.

Also drop getContext's inputType password check. menus.OnClickData has
no inputType, so it never fired; Firefox already withholds password
fields from selectionText via mozIsTextField(true) in SelectionUtils
(bug 565717).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 02:13:06 -06:00
golemandClaude Opus 5.5 519131c21f fix: cap huge selections before shortening
The shortcut and toolbar read window.getSelection() without a limit, so a
select-all on a very large page handed prepareAction millions of
characters. Every binary-search probe re-encoded the whole candidate
prefix: about 1.1 s for 5M characters, paid again by the dialog.

Each code point adds at least one character to the URL, so nothing past
the first MAX_URL_CHARS can fit. Cap there before any encoding. A capped
source never takes the ready path: renderPrompt trims, so a prefix of
mostly whitespace could fit and silently drop the rest without consent.

Output is unchanged: 2,000 random cases matched develop exactly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 01:32:22 -06:00
golem 78e94640e1 feat: add Ask ChatGPT toolbar action 2026-10-12 12:51:24 -06:00
golem 5308932bf1 feat: add advanced context actions and optional translation 2026-10-05 15:38:16 -06:00
golem 51bf4d5c01 fix: prefer the focused frame, bound model length, drop dead flag 2026-08-01 23:15:46 -06:00
golem d7821e3dc7 fix: stop $ sequences in selected text corrupting the prompt 2026-08-01 23:15:39 -06:00
golem 5365ec881e feat: add pure ChatGPT URL builder with unit tests 2026-08-01 22:04:31 -06:00
golem c49f6415af feat: add settings defaults and validation with unit tests 2026-08-01 21:59:47 -06:00