Repository navigation
Stop expanding PlaceholderAPI placeholders in player-authored inline prompt text - #109
Conversation
…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.
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
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.
CyR1en
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
LGTM — thanks for updating trustedOrigin to include DispatchMode.ATTACHMENT (/playerdelegate) and updating the docs and test.
Summary
Fixes a placeholder injection (code scan finding
sfind-4cc71472769c494085816c39745c32d7).PromptPresentationExpandersent 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:
PromptFactory.createFromTagroutes non-dialog inline tags through a new privatecreateInlineinstead of the presetcreatepath; the preset branch andcreate(Player, PromptDefinition, ...)are unchanged.trustedOriginis set byScreenManagerfor delegated sessions,DispatchMode.CONSOLE(/consoledelegate) andDispatchMode.ATTACHMENT(/playerdelegate). Both commands are restricted toConsoleCommandSender, so the command line is written by the console rather than typed by the recipient. The flag reaches the factory through a new four-argumentScreenCreator.create/PromptFactory.createFromTagoverload. Ordinary player commands (DispatchMode.NORMAL) stay untrusted.Behaviour change: PlaceholderAPI placeholders in inline tag text (
displayText,-ttitle/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 permissionpromptpaper.inline.placeholders. It is declareddefault: falseand is deliberately not a child ofpromptpaper.admin, so nobody gets it implicitly. Moving such text into a preset, or dispatching through/consoledelegateor/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:createFromTagnever reaches the expander for inline anvil and dialog tags, and expands exactly once with the permission.ScreenManagerTest:/consoledelegateand/playerdelegatesessions create screens withtrustedOrigin = true; a normal player session passesfalse../gradlew :prompt-paper:testand:prompt-paper:spotlessCheckpass 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