Skip to content

fix(curl_parser): support attached short options and combined flags (#1887) - #1959

Open
atharva081106 wants to merge 1 commit into
foss42:mainfrom
atharva081106:fix-curl-attached-and-combined-short-options-v2
Open

atharva081106 wants to merge 1 commit into
foss42:mainfrom
atharva081106:fix-curl-attached-and-combined-short-options-v2

Conversation

@atharva081106

Copy link
Copy Markdown

PR Description

This PR fixes an issue where cURL import silently dropped short options with attached values (e.g. -XDELETE, -XPUT, -HAccept:..., -d'{...}', -uuser:pass) and combined boolean flags (e.g. -sL, -sSL, -sXPOST).

Root Cause

Previously, tokens starting with - were filtered against recognizedAbbrs requiring an exact string match (e.g. -XDELETE != -X). Consequently, any attached value or combined flag group was discarded as an unknown short option, causing requests to fall back to default GET and losing headers, body data, or flags.

Changes

  • Pre-expands command line tokens before filtering:
    • If a token starts with a single dash and an option that takes an argument (e.g., -X, -H, -d, -u, -A, -b, -c, -e, -F, -o), it splits the option and the attached value into separate tokens.
    • If a token combines boolean flags (e.g., -sL), it decomposes them into individual flag tokens (-s, -L) while safely dropping unrecognized characters.
    • Supports combined flags immediately followed by an option with an attached value (e.g. -sXPOST -> -s, -X, POST).
  • Tracks when an option expects a value so values starting with a dash are preserved.
  • Added 8 unit tests in packages/curl_parser/test/curl_parser_test.dart covering all reported scenarios.

Related Issues

Video Demo

Demonstration verifying all 91 unit tests (including 8 new regression tests for #1887) passing 100% cleanly on Windows.

Checklist

  • I have gone through the contributing guide
  • I have updated my branch and synced it with project main branch before making this PR
  • I am using the latest Flutter stable branch (run flutter upgrade and verify)
  • I have run the tests (flutter test) and all tests are passing

Added/updated tests?

We encourage you to add relevant test cases.

  • Yes

Added 8 unit tests in packages/curl_parser/test/curl_parser_test.dart under group Attached short options and combined flags (#1887).

OS on which you have developed and tested the feature?

  • Windows
  • macOS
  • Linux

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.

cURL import ignores attached short options like -XDELETE and combined flags like -sL

1 participant