fix: reference 可能包含多个 url 字段
Signed-off-by: Jia Chao <jiac13@chinaunicom.cn>
This commit is contained in:
parent
809d87897e
commit
524b23e0d8
11
src/lib.rs
11
src/lib.rs
|
@ -521,14 +521,14 @@ impl Note {
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct Reference {
|
pub struct Reference {
|
||||||
pub r#type: String,
|
pub r#type: String,
|
||||||
pub url: String,
|
pub url: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Reference {
|
impl Reference {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Reference {
|
Reference {
|
||||||
r#type: String::new(),
|
r#type: String::new(),
|
||||||
url: String::new(),
|
url: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -537,8 +537,11 @@ impl Reference {
|
||||||
loop {
|
loop {
|
||||||
match xmlreader.next() {
|
match xmlreader.next() {
|
||||||
Ok(XmlEvent::StartElement { attributes, .. }) => {
|
Ok(XmlEvent::StartElement { attributes, .. }) => {
|
||||||
self.r#type = attributes[0].value.clone();
|
if xmlreader.depth == 3 {
|
||||||
self.url = xmlreader.next_characters();
|
self.r#type = attributes[0].value.clone();
|
||||||
|
} else {
|
||||||
|
self.url.push(xmlreader.next_characters());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(XmlEvent::EndElement { .. }) => {
|
Ok(XmlEvent::EndElement { .. }) => {
|
||||||
if xmlreader.depth < 3 {
|
if xmlreader.depth < 3 {
|
||||||
|
|
|
@ -54,7 +54,7 @@ fn cvrf_works() {
|
||||||
let reference_url = "https://www.openeuler.org/en/security/cve/detail.html?id=CVE-2023-45288";
|
let reference_url = "https://www.openeuler.org/en/security/cve/detail.html?id=CVE-2023-45288";
|
||||||
assert_eq!(cvrf.documentreferences.len(), 3);
|
assert_eq!(cvrf.documentreferences.len(), 3);
|
||||||
assert_eq!(cvrf.documentreferences[1].r#type, reference_type);
|
assert_eq!(cvrf.documentreferences[1].r#type, reference_type);
|
||||||
assert_eq!(cvrf.documentreferences[1].r#url, reference_url);
|
assert_eq!(cvrf.documentreferences[1].url[0], reference_url);
|
||||||
|
|
||||||
// producttree
|
// producttree
|
||||||
let producttree_productid = "openEuler-22.03-LTS";
|
let producttree_productid = "openEuler-22.03-LTS";
|
||||||
|
|
Loading…
Reference in New Issue
Block a user