Strip stray backslash-escaping in query preview-row markdown cells (1.22.33)#81
Merged
Merged
Conversation
PR #80 cleaned a term's own labels (term_info_queries.clean_label), but query preview rows are assembled in vfb_queries.py from raw Neo4j labels via apoc.text.format and never pass through that path. So an embedded neuron label containing an apostrophe (e.g. the NBLAST 'similar neurons' preview showing MBON01(y5B\'2a)_R) still carried the stray backslash into the name/thumbnail markdown cells. Add the same stray-quote stripping into encode_markdown_links -- the shared 'prepare a markdown cell for display' pass already responsible for securing URLs and bracket-encoding labels for these columns -- so every preview name/thumbnail/label cell is cleaned in one vectorised pass. Guarded on a cheap literal-backslash check so it stays essentially free on large frames. Bump version to 1.22.33. Adds network-free unit tests over encode_markdown_links. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RQZ8eMr398cK1bnzN2XTqK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #80. That PR stripped the stray backslash-before-quote artifact
(e.g.
y5B\'2a→y5B'2a) from a term's own labels viaterm_info_queries.clean_label. But query preview rows are assembled invfb_queries.pyfrom raw Neo4j labels (apoc.text.format("[%s](%s)", ...))and never pass through that path, so an embedded neuron label containing an
apostrophe still leaked the backslash into the preview
name/thumbnailmarkdown cells.
Concretely,
get_term_info('VFB_jrchk0e3')in 1.22.32 returns a clean top-levellabel but its NBLAST "similar neurons" preview still contains:
Because these aren't clean in the vfbquery response, they don't self-heal from
the v3-cached layer the way the term's own labels do.
Fix
Add the same stray-quote stripping into
encode_markdown_links— the shared"prepare a markdown cell for display" pass already responsible for securing
URLs and bracket-encoding labels for exactly these columns. Every preview
name/thumbnail/labelcell is now cleaned in one vectorised pass,covering both the image-markdown and label-shape branches. Guarded on a cheap
literal-backslash
str.containscheck so it stays essentially free on the largeframes this function was tuned for.
Mirrors
term_info_queries.clean_label(re.sub(r"\\(['\"])", r"\1", ...)) soa term's own labels and its query-preview labels are cleaned identically.
Testing
New network-free unit tests in
src/test/test_preview_stray_backslash.pyexercise
encode_markdown_linksdirectly on production-shaped (object-dtype)frames: link cells, image cells, clean-cell no-op, and null preservation. All
pass; the existing
test_label_stray_backslash_cleanedstill passes.Verified end-to-end against live data: on a freshly-computed (uncached)
production-shaped frame the patched encoder reduces stray backslash-quote
occurrences in the
VFB_jrchk0e3similar-neurons preview from 2 to 0.Version bumped to 1.22.33.
🤖 Generated with Claude Code
https://claude.ai/code/session_01RQZ8eMr398cK1bnzN2XTqK