Skip to content

fix(plugins): escape the slash in meme captions instead of opening a URL segment - #1173

Open
lihongyuan99 wants to merge 1 commit into
TencentCloud:developfrom
lihongyuan99:fix/meme-maker-escape-slash
Open

lihongyuan99 wants to merge 1 commit into
TencentCloud:developfrom
lihongyuan99:fix/meme-maker-escape-slash

Conversation

@lihongyuan99

@lihongyuan99 lihongyuan99 commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

make_meme() builds the image URL as https://api.memegen.link/images/<template>/<top>/<bottom>.png (src/octop/infra/agents/plugins/bundled/meme-maker/main.py:57), and _encode_segment() (:27) implements memegen's ~/_ escape table for -, _, space, ?, &, #, % — but not for /. A slash in a caption therefore opens a new URL path segment, and memegen resolves the request against a different template/text pair instead of failing:

  • top="to/be", bottom="_or not" → _encode_segment emits to/be, so the request is /images/doge/to/be/_or_not.png. That URL returns a byte-identical image to /images/doge/to/be.png (both 329650 bytes, sha256 69a08e14…): the bottom slot is filled with text taken from the middle of the top caption and the real bottom text is dropped.
  • The escaped form /images/doge/to~sbe/_or_not.png returns a different, correct image (330495 bytes, sha256 57671c76…).

Nothing is reported as an error, so the user gets a meme with silently wrong words. Meme text containing / ("to be/or not to be", "yes/no") is a realistic model output. ~s is the same escape family this function already emits for ?/&/#/%, and the service treats it as canonical — asking it for a raw < answers with a redirect to doge/i_~l3_you/x.png.

plugin.yaml version is bumped 0.1.0 → 0.1.1 because update_available in src/octop/infra/agents/plugins/manager.py:351 compares the catalog version with the installed copy — without a bump, users who already installed the plugin from the marketplace would never receive this fix.

Target branch

  • Base is develop (feature / fix — default)
  • Base is main (release/* or hotfix/* only)

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Refactor / chore
  • Release / hotfix

Test plan

All commands re-run on develop@4667bd7b; these are the equivalents of the CI steps (make lint / make typecheck / make test) run by hand — make all was not used because this clone has no dashboard/node_modules, so the pre-commit build step cannot run here.

  • Red first, before touching the plugin: uv run pytest -q tests/unit/test_meme_maker_plugin.py → 3 failed in 1.51s (_encode_segment("a-b_c?d&e#f%g/h") returned a--b__c~qd~ae~hf~pg/h, and the built URL kept the raw slash).
  • Green after the fix: same command → 3 passed in 1.39s.
  • Plugin tree tests after the version bump: uv run pytest tests/unit/test_bundled_plugins_layout.py tests/unit/test_plugins.py tests/unit/test_plugin_manager.py tests/unit/test_plugin_seed.py tests/unit/test_meme_maker_plugin.py -q → 43 passed.
  • uv run ruff check src tests → All checks passed; uv run ruff format --check src tests → 1081 files already formatted.
  • uv run mypy src/octop → Success: no issues found in 530 source files.
  • Full suite: uv run pytest -q -m "not live" -n auto → 3850 passed, 17 skipped, 0 failed (the develop@4667bd7b baseline measured on this same tree beforehand is 3847 passed / 17 skipped, so +3 = the new test file, no regressions). The plugin.yaml version line changed while that run was in flight, so the five plugin-tree test files were re-run afterwards against the final tree — the 43 passed above, unchanged.
  • The new test stubs httpx.Client, so it needs no network and no API key; it asserts the requested URL is exactly /images/doge/to~sbe/_.png, that a slash in either caption cannot add a path segment, and that the rest of the escape table round-trips.

Checklist

  • Updated CHANGELOG.md (if user-facing)
  • README / docs updated (if needed)

Rebased onto develop@ded7addd on 2026-09-30. 1.0.2b4 and 1.0.2b5 both shipped since the previous base, and each release commit folded the whole ## [Unreleased] list into a version block, which emptied that section on develop — it is this branch's only conflict. The resolution keeps develop's CHANGELOG.md verbatim and re-inserts this PR's single bullet under a fresh ### 修复; nothing else changed.

Everything below was re-measured on develop@ded7addd. Backend gates were run by hand, as the equivalents of the CI steps (make lint / make typecheck / make test); make all was not used because this clone has no dashboard/node_modules.

  • Red, with this PR's fix reverted and only its tests: uv run pytest -q tests/unit/test_meme_maker_plugin.py -> 3 failed in 8.26s
  • Green as committed: the same command -> 3 passed in 1.51s
  • uv run ruff check src tests -> All checks passed!; uv run ruff format --check src tests -> 1112 files already formatted
  • uv run mypy src/octop -> Success: no issues found in 543 source files
  • Full suite uv run pytest -q -m "not live" -n 6 -> 3956 passed, 17 skipped, 1 failed in 215.38s, against 3953 passed, 17 skipped, 1 failed in 225.23s measured on the unmodified base commit in the same virtualenv. The single failure in both runs is tests/unit/test_plugin_manager.py::test_install_plugin_importing_legacy_harness_agent: legacy_imports.ensure_legacy_harness_agent_alias() deliberately leaves a real harness_agent distribution alone, and this local venv has an out-of-lock orcakit-harness-agent installed, so the alias assertion cannot hold here. It is pre-existing on the base, not a case this PR adds, and it is green in CI, which installs strictly from uv.lock (the Python 3.12 quality job is success on both this branch's pre- and post-rebase heads).
  • tests/live was not run; no model API key, PostgreSQL or Docker was needed.

Rebased onto develop@83b2ae2e7 (2026-10-03).

Four commits landed on develop since this branch's previous base (a02e3e18e): LDAP directory login (#1123), propagating exhausted model retries as failures (#1012), and two dashboard fixes (#1429, #1241) — each appended a bullet to ## [Unreleased], so CHANGELOG.md is this PR's only conflict. The resolution keeps develop's CHANGELOG.md verbatim and re-inserts this PR's single line into the existing ### 修复 list: git diff origin/develop ad69fe90d -- CHANGELOG.md is +1/-0, and git diff 8cd5da6308 ad69fe90d9 over every non-CHANGELOG file of the PR is empty, i.e. the code you already reviewed is byte-identical.

Re-measured on the new base with the same commands and the same virtualenv as the Test plan above:

  • ruff check src tests → All checks passed!
  • ruff format --check src tests → 1134 files already formatted
  • mypy src/octop → Success: no issues found in 551 source files
  • this PR's own tests: pytest -q tests/unit/test_meme_maker_plugin.py → 3 passed in 3.41s
  • full suite pytest -q -m "not live" -n 3 → 1 failed, 4135 passed, 17 skipped, 13 warnings in 416.65s (0:06:56) (three branches measured concurrently, so the wall time is inflated), against 4132 passed, 17 skipped, 1 failed in 218.55s measured on the unmodified base 83b2ae2e7 in this same virtualenv: +3 cases against the base, which are exactly this PR's. The single failure in both runs is the pre-existing local artifact tests/unit/test_plugin_manager.py::test_install_plugin_importing_legacy_harness_agent — this venv has an out-of-lock orcakit-harness-agent distribution installed, and that test deliberately leaves a real harness_agent package alone, so its alias assertion cannot hold here. It is red on the untouched base too and green in CI, which installs strictly from uv.lock.

2026-10-06 — CHANGELOG.md re-aligned with develop. A rebase of this branch had re-introduced other PRs' release-note bullets into the released ## [1.0.2b6] block, so this PR's diff carried those foreign lines instead of only its own. CHANGELOG.md is now develop's file verbatim plus this PR's single bullet under ## [Unreleased] → ### 修复:

  • git diff --numstat 75c274aef 905c03ae3 -- CHANGELOG.md → 1\t0\tCHANGELOG.md
  • git diff --name-only b2c2456eb 905c03ae3 → CHANGELOG.md only, so every code and test file is byte-identical to the head that Python 3.12 and Windows / Python 3.12 both reported success on;
    the commands and counts under Test plan therefore still describe this diff.
  • CHANGELOG.md at 75c274aef is identical to today's develop tip, so this does not need a fresh rebase.

Rebased onto develop@97d6e7ff4 (2026-10-12); head 905c03ae3 -> d50d424d3.

CHANGELOG.md is again this branch's only conflict, and the resolution keeps develop's file
verbatim and re-inserts only this PR's own bullet under its matching ### subsection — checked
mechanically: the diff against the new base is 1 added / 0 deleted in CHANGELOG.md
and byte-identical (hunk headers aside) for 3 code/test file(s) before and after the
rebase. Gates re-run by hand on the new head (make all still does not apply — no
dashboard/node_modules in this clone; the venv is created per worktree so
/Users/macos/Documents/Qoder/octop-pr-mining/repos/wt-r-1173/src/octop/__init__.py is this branch's own code):

  • targeted tests for this branch: 3 passed in 17.77s
  • full suite: 4630 passed, 26 skipped, 17 warnings in 440.28s (0:07:20), against develop@97d6e7ff4 measured in the same venv: 4627 passed, 26 skipped, 0 failed
  • All checks passed!; 1180 files already formatted; Success: no issues found in 570 source files

Rebased onto develop@87a8d52c2 (2026-10-14); head d50d424d3 -> 81e92405f.

CHANGELOG.md is again the only conflict. develop's file is kept verbatim and this PR's own
bullet is re-inserted into the current ## [Unreleased] list, which is now flat (no ###
subsections), so the diff against the new base is 1 added / 0 deleted there and the
3 code/test file(s) are byte-identical before and after (hunk headers aside) — checked
mechanically, not by eye. Gates re-run by hand on the new head (make all still does not apply:
no dashboard/node_modules in this clone; the venv belongs to this worktree, so
/Users/macos/Documents/Qoder/octop-pr-mining/repos/wt-r-1173/src/octop/__init__.py is this branch's own code):

  • RC ruff=0 format=0 mypy=0 targeted=0 full=0
  • targeted tests for this branch: 3 passed in 6.92s
  • full suite: 4682 passed, 26 skipped, 41 warnings in 239.56s (0:03:59), against develop@87a8d52c2 measured in the same environment today: 4679 passed, 26 skipped, 0 failed
  • All checks passed!; 1186 files already formatted; Success: no issues found in 571 source files

Rebased onto develop@99e479a6b (2026-10-16); head ac29aef99 -> 7a02e72b9.

CHANGELOG.md was again the only conflict: develop's file is kept verbatim and this PR's own bullet is re-inserted under its matching ### subsection of the current ## [Unreleased] block, so the diff against the new base is 1 added / 0 deleted there and the 3 code/test file(s) are byte-identical before and after the rebase (checked mechanically on the patch hash, not by eye). Gates re-run by hand on the new head (make all still does not apply — no dashboard/node_modules in this clone; the venv belongs to this worktree, so the checkout under test is this branch's own code):

  • RC ruff=0 format=0 mypy=0 targeted=0 full=0
  • targeted tests for this branch: 3 passed in 12.04s
  • full suite: 4783 passed, 32 skipped, 41 warnings in 400.38s (0:06:40), against develop@99e479a6b measured today in its own per-worktree venv on the same machine: 4780 passed, 32 skipped, 0 failed in 495.68s
  • All checks passed!; 1204 files already formatted; Success: no issues found in 581 source files

@lihongyuan99
lihongyuan99 force-pushed the fix/meme-maker-escape-slash branch 5 times, most recently from ad69fe9 to a898da7 Compare October 3, 2026 14:39
@lihongyuan99
lihongyuan99 force-pushed the fix/meme-maker-escape-slash branch 3 times, most recently from 905c03a to d50d424 Compare October 11, 2026 23:33
@lihongyuan99
lihongyuan99 force-pushed the fix/meme-maker-escape-slash branch 2 times, most recently from 81e9240 to ac29aef Compare October 14, 2026 23:25
@lihongyuan99
lihongyuan99 force-pushed the fix/meme-maker-escape-slash branch from ac29aef to 7a02e72 Compare October 15, 2026 23:22

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant