scep/transport: remove no-op url.PathUnescape call#1
Merged
sergey-cheperis merged 2 commits intofix/scep-pkiop-plus-sign-url-queryfrom Apr 9, 2026
Conversation
Agent-Logs-Url: https://github.com/sergey-cheperis/fleet/sessions/a348c85d-2d08-4d52-a56f-95ecdc44875d Co-authored-by: sergey-cheperis <12729914+sergey-cheperis@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Remove net/url import and update message function
scep/transport: remove no-op url.PathUnescape call
Apr 9, 2026
sergey-cheperis
approved these changes
Apr 9, 2026
795cb96
into
fix/scep-pkiop-plus-sign-url-query
2 checks passed
There was a problem hiding this comment.
Pull request overview
Removes a redundant URL unescaping step in SCEP PKIOperation message handling, since the query parameter is already unescaped when retrieved via r.URL.Query().Get("message").
Changes:
- Dropped the no-op
url.PathUnescapecall and intermediarymsg2variable inmessage()forPKIOperation. - Removed the now-unused
"net/url"import. - Kept the existing space-to-plus normalization and base64 decoding, now operating directly on
msg.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
url.PathUnescapein themessage()function'sPKIOperationbranch was a no-op:msgis obtained viar.URL.Query().Get("message"), which internally callsurl.QueryUnescape— so%XXsequences are already decoded beforeurl.PathUnescapeever sees them.Changes
server/mdm/scep/server/transport.go"net/url"import (no longer referenced)url.PathUnescape+msg2intermediary;strings.ReplaceAllandbase64.StdEncoding.DecodeStringnow operate directly onmsgBefore:
After:
Checklist for submitter
If some of the following don't apply, delete the relevant line.
SELECT *is avoided, SQL injection is prevented (using placeholders for values in statements), JS inline code is prevented especially for url redirects, and untrusted data interpolated into shell scripts/commands is validated against shell metacharacters.Testing
Added/updated automated tests
Where appropriate, automated tests simulate multiple hosts and test for host isolation (updates to one hosts's records do not affect another)
QA'd all new/changed functionality manually
For unreleased bug fixes in a release candidate, one of:
Database migrations
COLLATE utf8mb4_unicode_ci).New Fleet configuration settings
If you didn't check the box above, follow this checklist for GitOps-enabled settings:
fleetctl generate-gitopsfleetd/orbit/Fleet Desktop
runtime.GOOSis used as needed to isolate changesOriginal prompt
In
server/mdm/scep/server/transport.go, make the following minimal changes — do NOT modify any other lines, and do NOT add or remove trailing newlines:"net/url"from the import block.messagefunction, replace theurl.PathUnescapeblock with a directstrings.ReplaceAll. Specifically, replace these lines:With:
No other changes. Do not modify any other functions, types, constants, comments, or whitespace elsewhere in the file. Do not add or remove a trailing newline — preserve the file's ending exactly as it is in the current branch.
The following is the prior conversation context from the user's chat exploration (may be truncated):
User: see fleetdm#43319 (comment)
input is always assumed base64 so never contains actual spaces. however I see that PathUnescape is a no-op. does it make sense to remove it?
Assistant: Yes, you're right —
url.PathUnescapeis effectively a no-op here and can be removed.Here's why:
msgis already decoded by the time it reachesurl.PathUnescapemsgis obtained viar.URL.Query().Get("message"), which internally callsurl.QueryUnescape. That means:%XXsequences → already decoded+→ already decoded (to space)So by the time
msghitsurl.PathUnescape(msg), there are no%XXsequences left to decode.url.PathUnescape(which handles%XXbut not+) is indeed a no-op at that point.The real fix is to not use
r.URL.Query()at all — parser.URL.RawQuerydirectly so+is never misinterpreted as a space. The pattern would be:With that approach,
url.PathUnescapeis not a no-op — it does the right job of decoding any%XX-encoded characters (e.g./sent as%2F) while preserving+as+. Thestrings.ReplaceAllworkaround can then be removed too.Summary:
r.URL.Query()):url.PathUnescapeis a no-op → safe to remove.r.URL.RawQuery):url.PathUnescapeis necessary and should stay.So yes, removing it from the current approach is fine, but the better fix is to switch to
RawQuery+PathUnescape, as the Copilot review comment already suggested.User: I'd like not to complicate things because current fix does not introduce a regression. Let's remove PathUnescape
Assistant: We're waiting for your response to the tool call confirmation dialog to continue.
User: @copilot Accepted Confirmation: Are you sure?
Assistant: We're waiting for your response to the tool call confirmation dialog to continue.
Done! Once you confirm, the commit will remove the no-op
url.PathUnescapecall and its error-handling block, and drop the now-unused"net/url"import. Themessagefunction in thePKIOperationbranch becomes simply:User: Do not change other methods and parts of the file!
Assistant: We're waiting for your response to the tool call confirmation dialog to continue.
User: @copilot Accepted Confirmation: Are you sure?
Assistant: You're right, sorry about that. Here is the exact updated file — only the
messagefunction body and theimportblock are changed; everything else is untouched: