Skip to content

Stop expanding PlaceholderAPI placeholders in player-authored inline prompt text - #109

Merged
CyR1en merged 3 commits into
developmentfrom
devin/1795622675-inline-tag-papi-origin
Nov 26, 2026
Merged

CyR1en merged 3 commits into
developmentfrom
devin/1795622675-inline-tag-papi-origin

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Summary

Fixes a placeholder injection (code scan finding sfind-4cc71472769c494085816c39745c32d7). PromptPresentationExpander sent every display string to PlaceholderAPI without knowing its origin, so a player allowed to use prompts could type e.g. /msg <%parseother_{Alice}_vault_eco_balance%> and have the resolved value shown on their prompt screen.

The expander now distinguishes the origins:

expand(player, def)                             // preset-sourced (presets.json): always expanded, unchanged
expandInline(player, def, trustedOrigin)        // new: definition mapped from an inline tag
expandInlineDialog(player, tag, trustedOrigin)  // inline dialog / compound tag

inline paths:
  trustedOrigin || player.hasPermission("promptpaper.inline.placeholders")
      ? expansion delegate (old behaviour)
      : text passed through unexpanded (still truncated to MAX_DISPLAY_LENGTH)

PromptFactory.createFromTag routes non-dialog inline tags through a new private createInline instead of the preset create path; the preset branch and create(Player, PromptDefinition, ...) are unchanged.

trustedOrigin is set by ScreenManager for delegated sessions, DispatchMode.CONSOLE (/consoledelegate) and DispatchMode.ATTACHMENT (/playerdelegate). Both commands are restricted to ConsoleCommandSender, so the command line is written by the console rather than typed by the recipient. The flag reaches the factory through a new four-argument ScreenCreator.create / PromptFactory.createFromTag overload. Ordinary player commands (DispatchMode.NORMAL) stay untrusted.

Behaviour change: PlaceholderAPI placeholders in inline tag text (displayText, -t title/subtitle, dialog sub-tags) typed by a player are no longer resolved by default. Servers that rely on this (for example a menu plugin making players run /cmd <a:Hi %player_name%>) must grant the new opt-in permission promptpaper.inline.placeholders. It is declared default: false and is deliberately not a child of promptpaper.admin, so nobody gets it implicitly. Moving such text into a preset, or dispatching through /consoledelegate or /playerdelegate, are the alternatives that need no permission.

Tests

  • PromptPresentationExpanderTest: a recording delegate is never called for an inline tag with %player_name% (mapped, dialog and compound sub-tag paths) but is still called for a preset definition; expansion still happens with the opt-in permission or a trusted origin; unexpanded inline text is still length-bounded.
  • PromptFactoryTest: createFromTag never reaches the expander for inline anvil and dialog tags, and expands exactly once with the permission.
  • ScreenManagerTest: /consoledelegate and /playerdelegate sessions create screens with trustedOrigin = true; a normal player session passes false.
  • ./gradlew :prompt-paper:test and :prompt-paper:spotlessCheck pass locally on JDK 25.

Link to Devin session: https://app.devin.ai/sessions/3af651e065854d32a3b2c51745b84b13
Open in Devin Desktop: https://app.devin.ai/desktop/session/3af651e065854d32a3b2c51745b84b13?variant=devin
Requested by: @CyR1en


🟢 Devin Review found nothing to fix · View findings · Follow Devin's work

Devin Review

…prompt text

Inline tag text comes from the command line the player typed, so it no longer
reaches the expansion delegate unless the player holds
promptpaper.inline.placeholders. Preset text is still expanded.
@devin-ai-integration

Copy link
Copy Markdown
Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

Inline tags in a /consoledelegate command line are written by the console,
not typed by the recipient, so carry that origin from ScreenManager into the
expander instead of gating on the recipient's opt-in permission.
/playerdelegate and ordinary player commands stay untrusted.

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@CyR1en CyR1en left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good fix for player-authored inline PAPI injection — separating preset expansion from inline expansion and gating inline expansion behind a default: false opt-in permission is clean and well-tested.

One issue to fix before merging: /playerdelegate (DispatchMode.ATTACHMENT) is also strictly console-only (PlayerDelegateCommand restricts senders to ConsoleCommandSender.class), so its command template is console-authored just like /consoledelegate. Treating DispatchMode.ATTACHMENT as untrusted will unnecessarily break inline PAPI placeholders in console-authored /playerdelegate commands. Please include DispatchMode.ATTACHMENT in trustedOrigin (and update the Javadoc/test accordingly).

PlayerDelegateCommand is restricted to ConsoleCommandSender, so
DispatchMode.ATTACHMENT command lines are trusted like DispatchMode.CONSOLE.

@CyR1en CyR1en left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — thanks for updating trustedOrigin to include DispatchMode.ATTACHMENT (/playerdelegate) and updating the docs and test.

@CyR1en
CyR1en merged commit 8e5c8bc into development Nov 26, 2026
4 checks passed
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