Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
3fa78598
Unverified
Commit
3fa78598
authored
May 09, 2025
by
Bruce MacDonald
Committed by
GitHub
May 09, 2025
Browse files
cmd: strip single quotes from image page (#10636)
parent
0d6e35d3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
cmd/interactive.go
cmd/interactive.go
+2
-0
cmd/interactive_test.go
cmd/interactive_test.go
+23
-0
No files found.
cmd/interactive.go
View file @
3fa78598
...
...
@@ -531,6 +531,8 @@ func extractFileData(input string) (string, []api.ImageData, error) {
return
""
,
imgs
,
err
}
fmt
.
Fprintf
(
os
.
Stderr
,
"Added image '%s'
\n
"
,
nfp
)
input
=
strings
.
ReplaceAll
(
input
,
"'"
+
nfp
+
"'"
,
""
)
input
=
strings
.
ReplaceAll
(
input
,
"'"
+
fp
+
"'"
,
""
)
input
=
strings
.
ReplaceAll
(
input
,
fp
,
""
)
imgs
=
append
(
imgs
,
data
)
}
...
...
cmd/interactive_test.go
View file @
3fa78598
package
cmd
import
(
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
...
...
@@ -50,3 +52,24 @@ d:\path with\spaces\seven.JPEG inbetween7 c:\users\jdoe\eight.png inbetween8
assert
.
Contains
(
t
,
res
[
9
],
"ten.PNG"
)
assert
.
Contains
(
t
,
res
[
9
],
"E:"
)
}
// Ensure that file paths wrapped in single quotes are removed with the quotes.
func
TestExtractFileDataRemovesQuotedFilepath
(
t
*
testing
.
T
)
{
dir
:=
t
.
TempDir
()
fp
:=
filepath
.
Join
(
dir
,
"img.jpg"
)
data
:=
make
([]
byte
,
600
)
copy
(
data
,
[]
byte
{
0xff
,
0xd8
,
0xff
,
0xe0
,
0x00
,
0x10
,
'J'
,
'F'
,
'I'
,
'F'
,
0x00
,
0x01
,
0x01
,
0x01
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0xff
,
0xd9
,
})
if
err
:=
os
.
WriteFile
(
fp
,
data
,
0
o600
);
err
!=
nil
{
t
.
Fatalf
(
"failed to write test image: %v"
,
err
)
}
input
:=
"before '"
+
fp
+
"' after"
cleaned
,
imgs
,
err
:=
extractFileData
(
input
)
assert
.
NoError
(
t
,
err
)
assert
.
Len
(
t
,
imgs
,
1
)
assert
.
Equal
(
t
,
cleaned
,
"before after"
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment