Skip to content

fix(jira): preserve escaped emphasis delimiters in jira_to_markdown - #1614

Merged
sooperset merged 1 commit into
sooperset:mainfrom
barrygfox:pr/escaped-emphasis-delimiters
Aug 24, 2026
Merged

fix(jira): preserve escaped emphasis delimiters in jira_to_markdown#1614
sooperset merged 1 commit into
sooperset:mainfrom
barrygfox:pr/escaped-emphasis-delimiters

Conversation

@barrygfox

Copy link
Copy Markdown
Contributor

Problem

JiraPreprocessor.jira_to_markdown() pairs emphasis delimiters positionally with ([*_])(.*?)\1, ignoring wiki escape markers. Stored content containing escaped intraword underscores is rewritten on every read-back:

  • stored wiki bytes: QUALITY\_GATES\_LLM\_ENABLED
  • returned "markdown": QUALITY\*GATES\*LLM\_ENABLED

Each round-trip through any read tool rewrites \_ to \*, silently corrupting content for MCP clients and any agent that treats the response as ground truth. Tracked by #1610.

Solution

Delimiters preceded by a backslash are wiki escapes written by this module's own markdown_to_jira (intraword \_ protection), not markup. The pairing regex now rejects escaped delimiters via negative lookbehind, so they can neither open nor close a span:

r"(?<!\\)([*_])(.*?)(?<!\\)\1"

Changes

src/mcp_atlassian/preprocessing/jira.py

Change Why
Emphasis regex gains (?<!\\) lookbehinds on open/close delimiter Escaped delimiters are literal text, not markup

tests/unit/preprocessing/test_preprocessing.py

  • test_jira_to_markdown additions — escaped \_ / \* sequences survive conversion unchanged; unescaped emphasis still converts

What Does Not Change

  • Unescaped emphasis conversion is byte-for-byte identical (*bold***bold**, _italic_*italic*)
  • Write path (markdown_to_jira) untouched
  • No new dependencies; no API/config changes

Breaking Changes

None.

Regression Tests

Fails before the fix (tests/unit/preprocessing/test_preprocessing.py::test_jira_to_markdown, against 436b37e):

E       AssertionError: assert 'QUALITY\\*GA...LLM\\_ENABLED' == 'QUALITY\\_GA...LLM\\_ENABLED'
E         - QUALITY\_GATES\_LLM\_ENABLED
E         + QUALITY\*GATES\*LLM\_ENABLED

Result: FAIL before, PASS after this commit.

Test Plan

  • pytest tests/unit/preprocessing/ -q — 173 passed
  • pytest tests/unit -q — full suite green on the combined stack

Fixes #1610

@sooperset
sooperset merged commit 9b66129 into sooperset:main Aug 24, 2026
8 checks passed
@mcp-atlassian-maintainer

Copy link
Copy Markdown
Contributor

Merged, thanks @barrygfox. The focused regex change and regression cases preserve escaped Jira identifiers while keeping real emphasis conversion intact.

@barrygfox
barrygfox deleted the pr/escaped-emphasis-delimiters branch August 25, 2026 02:26
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.

jira_to_markdown pairs escaped emphasis delimiters, rewriting stored \_ as \* on read-back

2 participants