You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// - Control characters except tab (U+0009), line feed (U+000A), and carriage return (U+000D)
116
+
// - Null character (U+0000)
117
+
// - Characters in the range U+007F to U+009F
118
+
(u <= 0x001F && u != 0x0009 && u != 0x000A && u != 0x000D) || (0x007F..=0x009F).contains(&u)
119
+
})
120
+
}
121
+
101
122
#[cfg(test)]
102
123
mod tests {
103
124
@@ -119,6 +140,63 @@ mod tests {
119
140
);
120
141
}
121
142
143
+
#[test]
144
+
fntest_failure_with_control_serialization(){
145
+
let f = Failure{
146
+
message:"Failed to build".to_string(),
147
+
tpe_name:"BuildFailure".to_string(),
148
+
value:"System failed to build\u{0000}".to_string(),
149
+
};
150
+
151
+
assert_eq!(
152
+
xml_writable_to_string(&f),
153
+
"<?xml version=\"1.0\" encoding=\"utf-8\"?><failure message=\"Failed to build\" type=\"BuildFailure\">System failed to build\0</failure>".to_string()
154
+
);
155
+
156
+
let f1 = Failure{
157
+
message:"Failed to build".to_string(),
158
+
tpe_name:"BuildFailure".to_string(),
159
+
value:"System failed to build]]>".to_string(),
160
+
};
161
+
162
+
assert_eq!(
163
+
xml_writable_to_string(&f1),
164
+
"<?xml version=\"1.0\" encoding=\"utf-8\"?><failure message=\"Failed to build\" type=\"BuildFailure\">System failed to build]]></failure>".to_string()
165
+
);
166
+
167
+
let f2 = Failure{
168
+
message:"Failed to build".to_string(),
169
+
tpe_name:"BuildFailure".to_string(),
170
+
value:"System failed to build <sometag>".to_string(),
171
+
};
172
+
173
+
assert_eq!(
174
+
xml_writable_to_string(&f2),
175
+
"<?xml version=\"1.0\" encoding=\"utf-8\"?><failure message=\"Failed to build\" type=\"BuildFailure\"><![CDATA[System failed to build <sometag>]]></failure>".to_string()
176
+
);
177
+
178
+
let f3 = Failure{
179
+
message:"Failed to build".to_string(),
180
+
tpe_name:"BuildFailure".to_string(),
181
+
value:"System failed to build <sometag> and ]]>".to_string(),
182
+
};
183
+
184
+
assert_eq!(
185
+
xml_writable_to_string(&f3),
186
+
"<?xml version=\"1.0\" encoding=\"utf-8\"?><failure message=\"Failed to build\" type=\"BuildFailure\">System failed to build <sometag> and ]]></failure>".to_string()
187
+
);
188
+
let f4 = Failure{
189
+
message:"Failed to build".to_string(),
190
+
tpe_name:"BuildFailure".to_string(),
191
+
value:"System failed to build \u{009F}".to_string(),
192
+
};
193
+
194
+
assert_eq!(
195
+
xml_writable_to_string(&f4),
196
+
"<?xml version=\"1.0\" encoding=\"utf-8\"?><failure message=\"Failed to build\" type=\"BuildFailure\">System failed to build \u{9F}</failure>".to_string()
0 commit comments