Skip to content

Fix escaping of REQUEST-STATUS field separators - #2124

Open
Prajas02 wants to merge 3 commits into
PyCalendar:mainfrom
Prajas02:fix-request-status-escaping
Open

Prajas02 wants to merge 3 commits into
PyCalendar:mainfrom
Prajas02:fix-request-status-escaping

Conversation

@Prajas02

Copy link
Copy Markdown

Closes #2123

What this changes

REQUEST-STATUS was written with escaped field separators (2.0\;Success), which is not valid RFC 5545 and is not readable by other clients. Parsing also split a field at an escaped \;.

vRequestStatus already stores its value in the escaped wire form (new() escapes each field and the description/data accessors unescape them), so the fix makes the reader and writer agree with that:

  • vRequestStatus.to_ical() writes the value as is, without escaping the separators again.
  • vRequestStatus.get_value_from_content_line() hands the raw, still escaped value to the type. This uses the hook the parser already offers for value types that must not be unescaped (as vUnknown does).
  • Values written by older versions of icalendar (2.0\;Success) are detected and unescaped once, so existing files are still read correctly.
  • Newlines in the description or data are escaped as \n, so they cannot break the content line.

Before / after

Input or call Before After
vRequestStatus.new("3.1", "Invalid property value", "DTSTART:96-Apr-01") 3.1\;Invalid property value\;DTSTART:96-Apr-01 3.1;Invalid property value;DTSTART:96-Apr-01
parse 2.0;Success\; with note;x\,y description Success, data with note;x,y description Success; with note, data x,y
parse legacy 2.0\;Success (2, 0), Success (2, 0), Success

Tests

  • Every RFC 5545 example is written without escaped separators, parsed into the right fields, and survives parse then serialize byte for byte.
  • Values written by older versions are still parsed.
  • Newlines in fields are escaped and round trip.

14 of the new tests fail on main and pass with this change. The full test suite and ruff pass.

Checklist

  • Tests added
  • News fragment added in news/
  • I used AI to assist me with this change and reviewed the result.

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for the pull request, @Prajas02! A maintainer will review it shortly.

@github-actions

Copy link
Copy Markdown
Contributor

Insufficient data

Not enough activity yet to make a reliable assessment.

View full analysis →

This is an automated analysis by AgentScan

@github-actions github-actions Bot added the ai-suspicion This contribution is possibly created with lots of AI help without enough human understanding. label Nov 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

One or more PR-quality checks did not pass. Review the PR Quality Checks summary in the workflow run for the failed checks and their details, then make any necessary updates.

Checklist items may remain unchecked while work is in progress. Please tick each item as you complete it.

If you used AI assistance, follow the project's Responsible AI use policy and provide the required disclosures.

@angatha

angatha commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

Thank you for the contribution. Please follow our responsible AI usage and clarify how you used AI. The policy is linked below. PLease read it.

Prajas02 and others added 2 commits November 17, 2026 23:57
AI assistance: Google Antigravity (Gemini 3.8 Flash) helped update the changelog entry and format the disclosure per policy.
@Prajas02

Copy link
Copy Markdown
Author

Hi @angatha

Thank you for pointing me to the Responsible AI use policy. I appreciate the project's standards on transparency and maintainer time, and I am glad to provide the complete disclosure and clarify how AI was used for this PR.

1. AI Tool & Model Disclosure

  • Tool / Environment: Google Antigravity
  • Model & Version: Gemini 3.8 Flash

2. How AI Was Used (Prompts & Interactions Summary)

  • RFC Analysis: Used to review RFC 5545 Section 3.8.8.3 grammar (statcode ";" statdesc [";" extdata]) to confirm that semicolons between the status code, description, and extra data are structural separators rather than text values that should be escaped.
  • Root Cause & Implementation: Identified that vRequestStatus improperly inherited default vText.to_ical() escaping, resulting in 2.0\;Success. AI was used to draft the fix in src/icalendar/prop/request_status.py, specifically:
    • Adding _escape_field() to escape semicolons/commas within individual field contents rather than across the full property.
    • Adding a custom to_ical() avoiding re-escaping structural delimiters.
    • Updating get_value_from_content_line() with backwards compatibility (LEGACY_ESCAPED_SEPARATOR) so legacy values written by older versions can still be read.
  • Test Generation: Drafted regression test cases in src/icalendar/tests/prop/test_request_status.py covering serialization, round-trip parsing, backward compatibility, and embedded newline escaping.

3. Responsibility & Validation

  • Code Understanding: I understand and can explain all design and code decisions in this PR.
  • Manual Verification: I personally reviewed and verified all code and docstrings. All 97 unit tests in test_request_status.py were run locally and pass.
  • Terms & Copyright: I confirmed adherence to the model's terms of use, and verified that no code or tests were reconstructed from copyrighted sources.
  • I take full responsibility for the submitted changes and future maintenance of this code.

4. Updates Made to PR

Please let me know if you would also like me to reword or amend the git commit messages on the branch.

This branch has not been deployed

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

Labels

ai-suspicion This contribution is possibly created with lots of AI help without enough human understanding.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

REQUEST-STATUS is serialized with escaped field separators and parsed incorrectly

2 participants