Skip to content

fix: split comma-separated entries when reading from file input#912

Closed
jcrewfare wants to merge 2 commits intoprojectdiscovery:mainfrom
jcrewfare:fix/list-comma-split
Closed

fix: split comma-separated entries when reading from file input#912
jcrewfare wants to merge 2 commits intoprojectdiscovery:mainfrom
jcrewfare:fix/list-comma-split

Conversation

@jcrewfare
Copy link
Copy Markdown

@jcrewfare jcrewfare commented Feb 19, 2026

Fixes #859
The -u flag correctly splits comma-separated values via CommaSeparatedStringSliceOptions, but -l and stdin pass entire lines to processInputItem without splitting.

Added strings.Split(text, ",") to both the file reader and stdin reader in normalizeAndQueueInputs, matching the behavior of -u.

Before:
echo '192.168.1.0/24,192.168.2.0/24' > targets.txt
tlsx -l targets.txt # treats entire line as one target

After:
tlsx -l targets.txt # splits and processes each entry separately

Summary by CodeRabbit

Release Notes

  • New Features
    • Input processing now accepts comma-separated items within each line for both file and standard-input sources. Multiple entries on a single line are split, trimmed of surrounding whitespace, and empty items are ignored — simplifying bulk entry and reducing manual formatting.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 19, 2026

No actionable comments were generated in the recent review. 🎉


Walkthrough

The change adds a helper to split comma-separated items on each input line and uses it in normalizeAndQueueInputs, so file-based and stdin lines are parsed into multiple trimmed items and each non-empty item is queued individually instead of treating the whole line as one input.

Changes

Cohort / File(s) Summary
Input parsing update
internal/runner/runner.go
Added processLine(text string, inputs chan taskInput) to split each input line by commas, trim items, and queue non-empty entries. Replaced direct line handling in normalizeAndQueueInputs for file and stdin branches to use the new helper.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A rabbit trims each comma, hops free,
Splitting lines into a lively spree,
No more one per row — now many play,
Queued and neat, they leap away! 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: splitting comma-separated entries when reading from file input, which is the core objective of this PR.
Linked Issues check ✅ Passed The PR directly addresses issue #859 by implementing comma-separated entry splitting for file and stdin inputs, matching the -u flag behavior as required.
Out of Scope Changes check ✅ Passed All changes are within scope: the processLine helper and its integration into file/stdin readers directly address the comma-splitting requirement from issue #859.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
internal/runner/runner.go (1)

443-448: Extract the repeated split-trim-process block into a helper to avoid duplication.

The identical four-line loop appears verbatim in both the InputList and stdin branches. Extracting it reduces future drift risk.

♻️ Proposed refactor

Add a small helper above normalizeAndQueueInputs:

+// processLine splits a comma-separated input line and queues each non-empty item.
+func (r *Runner) processLine(text string, inputs chan taskInput) {
+	for _, item := range strings.Split(text, ",") {
+		item = strings.TrimSpace(item)
+		if item != "" {
+			r.processInputItem(item, inputs)
+		}
+	}
+}

Then replace both duplicated blocks:

 		for scanner.Scan() {
 			text := scanner.Text()
 			if text != "" {
-				for _, item := range strings.Split(text, ",") {
-					item = strings.TrimSpace(item)
-					if item != "" {
-						r.processInputItem(item, inputs)
-					}
-				}
+				r.processLine(text, inputs)
 			}
 		}

(Apply the same diff to both the InputList and stdin scanner loops.)

Also applies to: 457-462

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/runner/runner.go` around lines 443 - 448, The
comma-split/trim/process loop is duplicated in normalizeAndQueueInputs (both the
InputList branch and the stdin scanner branch); extract it into a helper method
on Runner (e.g., func (r *Runner) processLine(text string, inputs chan
taskInput)) that performs strings.Split, strings.TrimSpace, filters empty
strings and calls r.processInputItem for each item, then replace both duplicated
four-line blocks with calls to r.processLine(text, inputs).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@internal/runner/runner.go`:
- Around line 443-448: The comma-split/trim/process loop is duplicated in
normalizeAndQueueInputs (both the InputList branch and the stdin scanner
branch); extract it into a helper method on Runner (e.g., func (r *Runner)
processLine(text string, inputs chan taskInput)) that performs strings.Split,
strings.TrimSpace, filters empty strings and calls r.processInputItem for each
item, then replace both duplicated four-line blocks with calls to
r.processLine(text, inputs).

@Mzack9999
Copy link
Copy Markdown
Member

Thank you for the contribution! This issue has been resolved by #953 which was merged with the same approach (splitting comma-separated entries in file and stdin input) along with a dedicated test. Closing as superseded.

@Mzack9999 Mzack9999 closed this Mar 19, 2026
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.

-l -list option does not understand multiple prefixes, comma-separated in a single line

2 participants