Skip to content

Commit

Permalink
vcf/variant/record/samples/series: Percent-decode character value
Browse files Browse the repository at this point in the history
  • Loading branch information
zaeleus committed Sep 11, 2024
1 parent 301fec8 commit 5006163
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions noodles-vcf/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

### Changed

* vcf/variant/record/samples/series/value/array/values: Percent-decode
character and string values.
* vcf/variant/record/samples/series/value: Percent-decode character and
string values.

### Fixed

Expand Down
8 changes: 4 additions & 4 deletions noodles-vcf/src/record/samples/sample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::{io, iter};

use super::Keys;
use crate::{
io::reader::record_buf::value::percent_decode,
variant::record::samples::series::{value::Array, Value},
Header,
};
Expand Down Expand Up @@ -154,7 +155,8 @@ fn parse_float_value(src: &str) -> io::Result<Value<'_>> {
}

fn parse_character_value(src: &str) -> io::Result<Value<'_>> {
let mut chars = src.chars();
let s = percent_decode(src).map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
let mut chars = s.chars();

if let Some(c) = chars.next() {
if chars.next().is_none() {
Expand All @@ -164,13 +166,11 @@ fn parse_character_value(src: &str) -> io::Result<Value<'_>> {

Err(io::Error::new(
io::ErrorKind::InvalidData,
"invalid character value",
"invalid character",
))
}

fn parse_string_value(src: &str) -> io::Result<Value<'_>> {
use crate::io::reader::record_buf::value::percent_decode;

percent_decode(src)
.map(Value::String)
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))
Expand Down

0 comments on commit 5006163

Please sign in to comment.