uttrflow / uttrflow/uttrflow-swift

Test the clipboard's HTML reader with spaces around '=', upper-case </SCRIPT> end tags and empty link text

Open Beginner friendly
#742 0 comments 0 reactions 0 assignees View on GitHub
area:clipboard enhancement good first issue P2
Dominant language
Swift
Stars
4
Forks
17
Avg merge
3h 32m
Merged PRs (30d)
277

Description

## What happens

`Sources/UttrflowClipboard/RichTextPlainForm.swift` turns copied HTML into plain text. These branches have never run:

- lines 181 and 185: whitespace before or after `=` in an attribute (``);
- line 237: an end tag for a raw-text element that differs only in case, such as `...` or `...`. Without the case-insensitive match, everything after it is skipped;
- line 232: a partial end tag at the very end of the input;
- lines 369, 459 and 491: appending empty content, empty verbatim text, and a space to a link that has no text yet;
- line 719: an `href` that starts with `:`, which has no scheme.

Measured on origin/main `26d7bc1` with `swift test --enable-code-coverage` (5,384 tests, all passing) and `xcrun llvm-cov export` over the test binary. The regions named below have an execution count of 0: no test runs them, so a change that breaks them passes `make verify`.

## Why it matters

HTML from web pages and mail is messy. If the case-insensitive end-tag match breaks, a copy containing an upper-case `` loses the rest of its text in history and in plain paste. If attribute whitespace breaks, links lose their targets.

## How to reproduce

Run `swift test --enable-code-coverage`, then `xcrun llvm-cov show -instr-profile .build/debug/codecov/default.profdata .build/debug/UttrflowPackageTests.xctest/Contents/MacOS/UttrflowPackageTests Sources/UttrflowClipboard/RichTextPlainForm.swift` and look for the `0` counts on the lines named above.

## Acceptance criteria

- `plainText(fromHTML: "p{}

kept

")` is "kept".
- `
site` keeps the link target wherever the plain form keeps links today.
- `x` does not crash and reads "x".
- Each new test fails when the branch it covers is broken. Check this by hand before opening the PR: temporarily change the branch (flip the condition or return the other value), see the test fail, then restore it.

## Where to start

- `Tests/UttrflowClipboardTests/RichTextPlainFormTests.swift`. It is table-driven, so add rows.

Read `CONTRIBUTING.md` first. Iterate with `swift test --filter `, then run `make verify` before pushing. Only tests change; no product code needs to.

**Size:** S.

Contributor guide

Open the contributing guide

Research direction

Read CONTRIBUTING.md, then open Tests/UttrflowClipboardTests/RichTextPlainFormTests.swift and add table-driven cases for the HTML inputs and uncovered branches named in the issue. Run the focused Swift test suite, verify each test fails when its branch is temporarily broken, and finish with make verify; done means the listed cases pass without changing product code.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
desktop, testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
90/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.