Skip to content

Commit

Permalink
fix: escape some feild
Browse files Browse the repository at this point in the history
  • Loading branch information
bokuweb committed Nov 1, 2024
1 parent 4c7bd61 commit 0a146fa
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
5 changes: 4 additions & 1 deletion docx-core/src/documents/elements/based_on.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use serde::{Serialize, Serializer};

use crate::documents::BuildXML;
use crate::escape::escape;
use crate::xml_builder::*;

#[derive(Debug, Clone, PartialEq)]
Expand All @@ -10,7 +11,9 @@ pub struct BasedOn {

impl BasedOn {
pub fn new(val: impl Into<String>) -> BasedOn {
BasedOn { val: val.into() }
BasedOn {
val: escape(&val.into()),
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion docx-core/src/documents/elements/link.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use serde::{Serialize, Serializer};

use crate::documents::BuildXML;
use crate::escape::escape;
use crate::xml_builder::*;

#[derive(Debug, Clone, PartialEq)]
Expand All @@ -10,7 +11,9 @@ pub struct Link {

impl Link {
pub fn new(val: impl Into<String>) -> Link {
Link { val: val.into() }
Link {
val: escape(&val.into()),
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion docx-core/src/documents/elements/paragraph_style.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use serde::{Serialize, Serializer};

use crate::documents::BuildXML;
use crate::escape::escape;
use crate::xml_builder::*;

#[derive(Debug, Clone, PartialEq)]
Expand All @@ -25,7 +26,9 @@ impl Default for ParagraphStyle {
impl ParagraphStyle {
pub fn new(val: Option<impl Into<String>>) -> ParagraphStyle {
if let Some(v) = val {
ParagraphStyle { val: v.into() }
ParagraphStyle {
val: escape(&v.into()),
}
} else {
Default::default()
}
Expand Down
5 changes: 4 additions & 1 deletion docx-core/src/documents/elements/run_style.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use serde::{Serialize, Serializer};

use crate::documents::BuildXML;
use crate::escape::escape;
use crate::xml_builder::*;

#[derive(Debug, Clone, PartialEq)]
Expand All @@ -18,7 +19,9 @@ impl Default for RunStyle {

impl RunStyle {
pub fn new(val: impl Into<String>) -> RunStyle {
RunStyle { val: val.into() }
RunStyle {
val: escape(&val.into()),
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion docx-core/src/documents/elements/style.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use serde::Serialize;

use crate::documents::BuildXML;
use crate::escape::escape;
use crate::types::*;
use crate::xml_builder::*;
use crate::StyleType;
Expand Down Expand Up @@ -47,7 +48,7 @@ impl Style {
pub fn new(style_id: impl Into<String>, style_type: StyleType) -> Self {
let default = Default::default();
Style {
style_id: style_id.into(),
style_id: escape(&style_id.into()),
style_type,
..default
}
Expand Down

0 comments on commit 0a146fa

Please sign in to comment.