Skip to content

Commit 6edcaab

Browse files
Always strip quoted ' ' and '\t' when stripquoted=true (#116)
1 parent 462fb55 commit 6edcaab

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/strings.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ function xparse(::Type{T}, source::Union{AbstractVector{UInt8}, IO}, pos, len, o
9797
code |= INVALID_QUOTED_FIELD | EOF
9898
@goto donedone
9999
end
100-
if options.stripquoted && b != options.wh1 && b != options.wh2
100+
# Always treat space ' ' and tab '\t' as whitespace when quoted
101+
if options.stripquoted && b != options.wh1 && b != options.wh2 && b != UInt8(' ') && b != UInt8('\t')
101102
lastnonwhitespacepos = pos
102103
end
103104
b = peekbyte(source, pos)

test/runtests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,10 @@ res = Parsers.xparse(String, " hey there "; delim=nothing, stripquoted=true)
279279
res = Parsers.xparse(String, " hey there "; delim=nothing, stripquoted=true, stripwhitespace=false)
280280
@test res.val.pos == 2 && res.val.len == 9
281281

282+
# https://github.com/JuliaData/Parsers.jl/issues/115
283+
res = Parsers.xparse(String, "{hey there } "; openquotechar='{', closequotechar='}', stripquoted=true, delim=' ', wh1=0x00)
284+
@test res.val.pos == 2 && res.val.len == 9
285+
282286
end # @testset "Core Parsers.xparse"
283287

284288
@testset "ints" begin

0 commit comments

Comments
 (0)