Skip to content

refactor(http): build FlexiBee URLs natively instead of ecomailcz/purl - #51

Merged
pekral merged 3 commits into
masterfrom
feat/replace-purl
Nov 12, 2026
Merged

pekral merged 3 commits into
masterfrom
feat/replace-purl

Conversation

@pekral

@pekral pekral commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #49

TL;DR

Odstraňuje závislost ecomailcz/purl. UrlBuilder skládá URL nativními funkcemi PHP (parse_url(), http_build_query()). Všechny vygenerované URL zůstávají stejné.

Navazuje na #48, proto míří do větve chore/pekral-tooling. Po mergi #48 se PR automaticky přesměruje na master.

Změny

  • UrlBuilder už nedědí z Purl\Url. Ze základní URL si bere schéma, přihlašovací údaje, hostitele a port. Přidá cestu, ve které jsou mezery jako %20 (jako dřív), a query přes http_build_query() s výchozím limit=0.
  • Základní URL bez schématu nebo hostitele (např. demo.flexibee.eu) se odmítne výjimkou EcomailFlexibeeRequestFail už při vytvoření klienta. Dřív se tiše vytvořila relativní URL a požadavek selhal až v cURL.
  • Název firmy v createRestoreUrl() se nově kóduje (rawurlencode()). Dřív by název s & nebo # přidal do URL parametr nebo ji uřízl. Názvy jen s mezerami dávají stejnou URL jako dřív.
  • Zpráva výjimky pro neplatnou základní URL neobsahuje samotnou URL, protože v ní můžou být přihlašovací údaje (user:heslo@).
  • ecomailcz/purl je odebraný z composer.json. Deprecations na PHP 8.4+ teď hlásí už jen rakit/validation (komentář v phpunit.xml upravený).

Merge danger

  • Dveře: two-way.
  • BC break (milestone 2.0.0):
    • UrlBuilder už nemá zděděné veřejné metody Purl\Url (setPath(), getUrl(), setQuery() …);
    • konstruktor už nepřijímá Purl\ParserInterface.
    • UrlBuilder používá interně jen Client, běžné použití klienta se nemění.

Testování

  • Srovnání výstupů starého a nového UrlBuilder: 96 URL ze 4 základních adres (s portem, s lomítkem na konci, s přihlašovacími údaji a cestou, bez portu) a s filtry obsahujícími mezery, závorky, uvozovky, &, #, ?, diakritiku apod. Výstupy jsou bajtově shodné (kromě názvu firmy u restore se znaky &/#, viz opravu výše).
  • Nové unit testy v tests/Http/QueryBuilderTest.php: všechny metody, zachování portu a přihlašovacích údajů, odmítnutí URL bez schématu.
  • composer check prochází, pokrytí změněných řádků je 30/30.

@pekral pekral added this to the 2.0.0 milestone Nov 12, 2026
@pekral
pekral marked this pull request as draft November 12, 2026 14:08
@pekral
pekral marked this pull request as ready for review November 12, 2026 14:15
@pekral

pekral commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator Author

CR status — converged

Status: converged after 2 review iterations · Critical 0 · Moderate 0

Resolved items

  • Restore company name interpolated into the query unencoded (Minor)
    • Why: createRestoreUrl('a&b') produced ?name=a&b, adding a query parameter; # truncated the URL.
    • Reason: the name was formatted into the URL string as-is (behavior inherited from purl).
    • Solution: rawurlencode() the name; covered by QueryBuilderTest::testEncodesCompanyNameInRestoreUrl.
    • Commit: dad02e8 — fix(http): encode the company name of a restore request
  • Invalid base URL echoed in the exception message (Minor)
    • Why: a URL like user:secret@host ended up in the exception message and logs.
    • Reason: the message interpolated the rejected value.
    • Solution: a fixed message without the value; covered by testRejectsBaseUrlWithoutSchemeOrHost.
    • Commit: b564198 — fix(http): keep credentials out of the invalid base URL message

@pekral

pekral commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator Author

Code Review

Status: clean
Counts: Critical 0 · Moderate 0 · Minor 0 · Refactoring 0
Last updated: 2026-11-12T14:29:45Z (head ef407c5, rebased on master after #48; diff now also removes the interim tests/bootstrap.php)
Issue tracker summary: no linked issue summary posted — #49 is the source issue (technical refactor)


Summary: 0 Critical · 0 Moderate · 0 Minor · 0 Refactoring · assignment conformance: conformant (#49: purl removed, URLs unchanged for the tested inputs, base URL without scheme or host rejected, UrlBuilder no longer extends Purl\Url) · reviewer comments: none

UrlBuilder no longer extends Purl\Url. It keeps scheme, user info, host
and port of the configured URL and appends the path (spaces encoded as
%20) and the http_build_query() query, exactly as purl did: the output
of every builder method is byte-identical for the tested inputs.

A base URL without scheme or host is now rejected when the client is
created instead of silently producing a relative URL.

BREAKING CHANGE: UrlBuilder no longer inherits the public Purl\Url API,
and its constructor no longer accepts a Purl\ParserInterface.

Closes #49
CR finding (Minor): createRestoreUrl() interpolated the company name
into the query string unencoded, so a name containing "&" or "#" added
query parameters or truncated the URL. The name is now rawurlencode()d;
names with spaces only produce the same URL as before.
CR finding (Minor): the exception for a base URL without scheme or host
echoed the URL, which can carry "user:password@" and would leak it into
logs. The message now names the problem without the value.
@pekral pekral reopened this Nov 12, 2026
@pekral
pekral changed the base branch from chore/pekral-tooling to master November 12, 2026 14:27
@pekral
pekral merged commit 897d32b into master Nov 12, 2026
4 checks passed
@pekral
pekral deleted the feat/replace-purl branch November 12, 2026 14:30
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.

Replace ecomailcz/purl with native URL building

1 participant