Skip to content

Fix line folding across escape sequences#1502

Open
kingrubic wants to merge 1 commit into
collective:mainfrom
kingrubic:fix/1501-avoid-folding-escapes
Open

Fix line folding across escape sequences#1502
kingrubic wants to merge 1 commit into
collective:mainfrom
kingrubic:fix/1501-avoid-folding-escapes

Conversation

@kingrubic

Copy link
Copy Markdown

Summary

  • fixes [Bug] Description wrapping can create an invalid event #1501 by avoiding folded line breaks between escape prefixes and their escaped characters
  • applies to TEXT backslash escapes (\n, \,, etc.) and RFC 6868 parameter escapes (^n, ^^, ^\')
  • adds a regression test covering both escape families
  • adds a towncrier bugfix fragment

Verification

  • uv run pytest src/icalendar/tests/test_parsing.py -k '1501'
  • uv run pytest src/icalendar/tests/test_parsing.py
  • uv run pytest (16090 passed, 28 skipped)
  • uv run ruff check src/icalendar/parser/string.py src/icalendar/tests/test_parsing.py
  • uv run ruff format --check src/icalendar/parser/string.py src/icalendar/tests/test_parsing.py

@github-actions

Copy link
Copy Markdown
Contributor

Profile summary:

GitHub user: kingrubic
🟡 Some concerns found with user's profile.
🟢 No concerns found with recent PR activity.
🟢 No concerns found with recent issue activity.

For a more detailed report, run `gh-profiler kingrubic`.
Full profile
GitHub user: kingrubic
🟡 Some concerns found with user's profile.
   🟢 Account age: 3 years
   🟡 Profile information:
        name: Bé Mi Agent
      Empty fields: company, blog, location, email, bio

🟢 No concerns found with recent PR activity.
   25 PRs opened in the last 21 days.
      0 opened against repos the user owns.
      0 opened against repos in publicly associated orgs.
      25 opened against external repos.

   🟢 4 of 25 external PRs closed without merging in the last 21 days.

🟢 No concerns found with recent issue activity.
   1 new issues opened in the last 21 days.
      0 opened in repos the user owns.
      0 opened in repos in publicly associated orgs.
      1 opened in external repos.

   🟢 0 external issues closed as NOT_PLANNED.
   🟢 0 external issues opened with the same title.

char_byte_len = len(char.encode(DEFAULT_ENCODING))
if current_chars and byte_count + char_byte_len >= limit:
# Avoid splitting escaped values such as TEXT backslash escapes
# or RFC 6868 parameter escapes across a folded line boundary.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I commented #1501 and asked for a newer RFC version for content line folding. If no one could provide a version explicitly forbidding splitting thouse sequence, can you please include the reason (compatibility) why we aren't following the SHOULD from RFC 5545 or at least link the issue so everyone seeing that code knows that this is intentional.

Besides that, the code looks great.

I would wait for an answer on the issue before accepting that.

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.

[Bug] Description wrapping can create an invalid event

2 participants