Skip to content

fix(web-portal): handle escape characters - #8645

Open
grantfitzsimmons wants to merge 2 commits into
mainfrom
issue-8644
Open

grantfitzsimmons wants to merge 2 commits into
mainfrom
issue-8644

Conversation

@grantfitzsimmons

@grantfitzsimmons grantfitzsimmons commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Fixes #8644

This PR makes it so our Web Portal exports sanitize backslashes to doubles backslashes in exported cell values so any literal Java-style sequences such as \\r, \\b, and \\f remain literal when processed by the portal.

I tested this quite a bit with the UWFC Web Portal export. That worked perfectly after this change, but before was causing an error upon ingestion.

Checklist

  • Self-review the PR after opening it to make sure the changes look good and
    self-explanatory (or properly documented)
  • Add relevant issue to release milestone
  • Add pr to documentation list
  • Add automated tests
  • Add a reverse migration if a migration is present in the PR
  • Add migration function to
    def fix_schema_config(stdout: WriteToStdOut | None = None):

Testing instructions


@grantfitzsimmons grantfitzsimmons added this to the 7.12.3 milestone Oct 7, 2026
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3d2116c7-fbde-40fb-9849-2b4f04729635
📥 Commits

Reviewing files that changed from the base of the PR and between 3dc37c8 and 68c0c1f.

📒 Files selected for processing (2)
  • specifyweb/backend/stored_queries/tests/test_views/test_export_web_portal.py
  • specifyweb/backend/stored_queries/web_portal_export.py

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.


📝 Walkthrough

Walkthrough

_clean_cell now replaces actual line breaks with spaces and doubles backslashes in exported cell values. A test covers literal escape sequences and actual line breaks.

Changes

Web Portal export cell cleaning

Layer / File(s) Summary
Clean exported cell values
specifyweb/backend/stored_queries/web_portal_export.py, specifyweb/backend/stored_queries/tests/test_views/test_export_web_portal.py
_clean_cell converts nulls to empty text, replaces carriage returns and newlines with spaces, and doubles backslashes. The test checks literal escape sequences and actual line breaks.

Suggested reviewers: melton-jason, carolinedenis

Priority: ⬆️ High

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 68c0c

The export cleanup has a focused test, and no specific failure requiring a fix before merge is established.

🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Testing Instructions ⚠️ Warning The PR description has an empty “Testing instructions” section. The diff changes _clean_cell in Web Portal export handling and adds a test for literal Java-style backslash sequences and actual newli… Add clear testing instructions that identify the Web Portal export behavior to verify, including literal backslash sequences and actual line breaks. Include the command or steps to run the relevant test in test_export_web_portal.py.
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue #8644 requires literal Java-style backslash sequences to remain literal in Web Portal exports. _clean_cell now replaces each backslash with a doubled backslash after normalizing actual CR and …
Out of Scope Changes check ✅ Passed The only changes update _clean_cell and add a focused test for the export behavior in issue #8644. No unrelated changes appear in the PR diff.
Automatic Tests ✅ Passed The PR adds test_clean_cell_preserves_literal_java_escape_sequences to the existing test_export_web_portal.py test module. It checks that literal \\r, \\b, \\f, and backslash sequences are esca…
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: handling escape characters in Web Portal exports.
Full details: Testing Instructions

Explanation

The PR description has an empty “Testing instructions” section. The diff changes _clean_cell in Web Portal export handling and adds a test for literal Java-style backslash sequences and actual newline/carriage-return characters. The instructions do not tell a reviewer how to test either affected behavior.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📋Back Log

Development

Successfully merging this pull request may close these issues.

Web Portal exports include literal escape sequences in exported text

1 participant