Skip to content

Commit dd321ab

Browse files
authored
nokia_sros: handle CRLF and tabs in partialCfg (#2382)
1 parent 2211b9b commit dd321ab

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

nodes/vr_sros/vr-sros.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,10 @@ func (s *vrSROS) applyPartialConfig(ctx context.Context, addr, platformName,
262262
return err
263263
}
264264

265+
configContentStr := string(configContent)
266+
265267
// check file contains content, otherwise exit early
266-
if strings.TrimSpace(string(configContent)) == "" {
268+
if strings.TrimSpace(configContentStr) == "" {
267269
return nil
268270
}
269271

@@ -315,8 +317,16 @@ func (s *vrSROS) applyPartialConfig(ctx context.Context, addr, platformName,
315317
}
316318
}
317319
}
318-
// converting byte slice to newline delimited string slice
319-
cfgs := strings.Split(string(configContent), "\n")
320+
321+
// Normalize character sequences to avoid interaction issues with CLI
322+
replacer := strings.NewReplacer(
323+
"\r\n", "\n", // replace EOL CRLF with LF
324+
"\t", " ", // replace tabs with 4 spaces
325+
)
326+
configContentStr = replacer.Replace(configContentStr)
327+
328+
// converting string to newline delimited string slice
329+
cfgs := strings.Split(configContentStr, "\n")
320330

321331
// config snippets should not have commit command, so we need to commit manually
322332
// and quit from the config mode

0 commit comments

Comments
 (0)