]> Cypherpunks repositories - gostls13.git/commitdiff
os: fix findOneDriveDir to expand REG_SZ registry values
authorGeorge Adams <georgeadams1995@gmail.com>
Wed, 30 Oct 2024 11:07:27 +0000 (11:07 +0000)
committerGopher Robot <gobot@golang.org>
Thu, 31 Oct 2024 19:21:20 +0000 (19:21 +0000)
On some Windows systems the SOFTWARE\Microsoft\OneDrive registry key is REG_SZ rather than REG_EXPAND_SZ.

Change-Id: I3ccb8771377a73456f48da1b5cfae668130b3f7b
Reviewed-on: https://go-review.googlesource.com/c/go/+/623515
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
src/os/os_windows_test.go

index d4cd61067e7f8e997267f5cd5295ea88ce94077b..9208fe3b16e3099adfda9378e25af4caa6818261 100644 (file)
@@ -931,7 +931,9 @@ func findOneDriveDir() (string, error) {
                return "", fmt.Errorf("reading UserFolder failed: %v", err)
        }
 
-       if valtype == registry.EXPAND_SZ {
+       // REG_SZ values may also contain environment variables that need to be expanded.
+       // It's recommended but not required to use REG_EXPAND_SZ for paths that contain environment variables.
+       if valtype == registry.EXPAND_SZ || valtype == registry.SZ {
                expanded, err := registry.ExpandString(path)
                if err != nil {
                        return "", fmt.Errorf("expanding UserFolder failed: %v", err)