Fix URI fragment parsing without query#6393
Conversation
Signed-off-by: Minh Vu <vuhoangminh97@gmail.com>
|
| Filename | Overview |
|---|---|
| dali/util/uri.cc | Core parse fix: authority/path loops now stop at '#', and the query section is guarded by 'if (*p == ?')'. Logic is correct for all reachable states after each loop. |
| dali/util/uri_test.cc | Five new tests cover the previously-untested fragment parsing shapes; expected values verified against the path_and_query() max(path_end_, query_end_) formula in uri.h. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[URI::Parse] --> B[Scheme loop\nstop at ':']
B --> C{'//' next?}
C -- yes --> D["Authority loop\nstop at '/', '?', '#' NEW"]
C -- no --> E
D --> E{*p == null?}
E -- yes --> Z[return parsed]
E -- no --> F["Path loop\nstop at '?', '#' NEW"]
F --> G{*p == null?}
G -- yes --> Z
G -- no --> H{"*p == '?' NEW guard"}
H -- yes --> I[Advance past '?'\nQuery loop\nstop at '#']
H -- no --> J
I --> K{*p == null?}
K -- yes --> Z
K -- no --> J["Advance past '#'\nFragment loop\nstop at null"]
J --> Z
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[URI::Parse] --> B[Scheme loop\nstop at ':']
B --> C{'//' next?}
C -- yes --> D["Authority loop\nstop at '/', '?', '#' NEW"]
C -- no --> E
D --> E{*p == null?}
E -- yes --> Z[return parsed]
E -- no --> F["Path loop\nstop at '?', '#' NEW"]
F --> G{*p == null?}
G -- yes --> Z
G -- no --> H{"*p == '?' NEW guard"}
H -- yes --> I[Advance past '?'\nQuery loop\nstop at '#']
H -- no --> J
I --> K{*p == null?}
K -- yes --> Z
K -- no --> J["Advance past '#'\nFragment loop\nstop at null"]
J --> Z
Reviews (3): Last reviewed commit: "Add authority-less URI fragment test" | Re-trigger Greptile
| EXPECT_EQ("", uri.path()); | ||
| EXPECT_EQ("query", uri.query()); | ||
| EXPECT_EQ("?query", uri.path_and_query()); | ||
| EXPECT_EQ("fragment", uri.fragment()); |
There was a problem hiding this comment.
All four new cases use s3:// URIs (with an authority). The path-loop # fix also fires on authority-less URIs such as urn:path#frag or mailto:user@example.com#section, but that code path is untested. Consider adding one case like URI::Parse("urn:path#frag") to cover the path-only branch.
Signed-off-by: Minh Vu <vuhoangminh97@gmail.com>
b9c4aa5 to
f29412a
Compare
|
@fallintoplace would you mind checking the review comment? |
|
!build |
|
CI MESSAGE: [56212093]: BUILD STARTED |
|
CI MESSAGE: [56212093]: BUILD PASSED |
|
@fallintoplace thank you for your contribution. |
Summary
?is present, sopath#fragmentreaches the fragment parser.Validation
git diff --checkdali/util/uri.ccFull gtest was not run locally because this checkout does not have a configured build directory.