fix: use better way to remove quotes
This commit is contained in:
parent
780ec7f9d6
commit
de06c8f38b
|
@ -135,7 +135,7 @@ Future<void> completeMultipartUpload(
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.toList(),
|
.toList(),
|
||||||
});
|
}).replaceAll('"', '').replaceAll('"', '');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await _dio.post(
|
await _dio.post(
|
||||||
|
|
|
@ -41,95 +41,3 @@ void buildXml(XmlBuilder builder, dynamic node) {
|
||||||
builder.text(node.toString());
|
builder.text(node.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// for removing the " from the xml string response.
|
|
||||||
// couldn't find better way to do this
|
|
||||||
XmlEntityMapping defaultMyEntityMapping = MyXmlDefaultEntityMapping.xml();
|
|
||||||
|
|
||||||
class MyXmlDefaultEntityMapping extends XmlDefaultEntityMapping {
|
|
||||||
MyXmlDefaultEntityMapping.xml() : this(xmlEntities);
|
|
||||||
MyXmlDefaultEntityMapping.html() : this(htmlEntities);
|
|
||||||
MyXmlDefaultEntityMapping.html5() : this(html5Entities);
|
|
||||||
MyXmlDefaultEntityMapping(super.entities);
|
|
||||||
|
|
||||||
@override
|
|
||||||
String encodeText(String input) =>
|
|
||||||
input.replaceAllMapped(_textPattern, _textReplace);
|
|
||||||
|
|
||||||
@override
|
|
||||||
String encodeAttributeValue(String input, XmlAttributeType type) {
|
|
||||||
switch (type) {
|
|
||||||
case XmlAttributeType.SINGLE_QUOTE:
|
|
||||||
return input.replaceAllMapped(
|
|
||||||
_singeQuoteAttributePattern,
|
|
||||||
_singeQuoteAttributeReplace,
|
|
||||||
);
|
|
||||||
case XmlAttributeType.DOUBLE_QUOTE:
|
|
||||||
return input.replaceAllMapped(
|
|
||||||
_doubleQuoteAttributePattern,
|
|
||||||
_doubleQuoteAttributeReplace,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final _textPattern = RegExp(r'[&<>' + _highlyDiscouragedCharClass + r']');
|
|
||||||
|
|
||||||
String _textReplace(Match match) {
|
|
||||||
final toEscape = match.group(0)!;
|
|
||||||
switch (toEscape) {
|
|
||||||
case '<':
|
|
||||||
return '<';
|
|
||||||
case '&':
|
|
||||||
return '&';
|
|
||||||
case '>':
|
|
||||||
return '>';
|
|
||||||
default:
|
|
||||||
return _asNumericCharacterReferences(toEscape);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final _singeQuoteAttributePattern =
|
|
||||||
RegExp(r"['&<>\n\r\t" + _highlyDiscouragedCharClass + r']');
|
|
||||||
|
|
||||||
String _singeQuoteAttributeReplace(Match match) {
|
|
||||||
final toEscape = match.group(0)!;
|
|
||||||
switch (toEscape) {
|
|
||||||
case "'":
|
|
||||||
return '';
|
|
||||||
case '&':
|
|
||||||
return '&';
|
|
||||||
case '<':
|
|
||||||
return '<';
|
|
||||||
case '>':
|
|
||||||
return '>';
|
|
||||||
default:
|
|
||||||
return _asNumericCharacterReferences(toEscape);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final _doubleQuoteAttributePattern =
|
|
||||||
RegExp(r'["&<>\n\r\t' + _highlyDiscouragedCharClass + r']');
|
|
||||||
|
|
||||||
String _doubleQuoteAttributeReplace(Match match) {
|
|
||||||
final toEscape = match.group(0)!;
|
|
||||||
switch (toEscape) {
|
|
||||||
case '"':
|
|
||||||
return '';
|
|
||||||
case '&':
|
|
||||||
return '&';
|
|
||||||
case '<':
|
|
||||||
return '<';
|
|
||||||
case '>':
|
|
||||||
return '>';
|
|
||||||
default:
|
|
||||||
return _asNumericCharacterReferences(toEscape);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const _highlyDiscouragedCharClass =
|
|
||||||
r'\u0001-\u0008\u000b\u000c\u000e-\u001f\u007f-\u0084\u0086-\u009f';
|
|
||||||
|
|
||||||
String _asNumericCharacterReferences(String toEscape) => toEscape.runes
|
|
||||||
.map((rune) => '&#x${rune.toRadixString(16).toUpperCase()};')
|
|
||||||
.join();
|
|
||||||
|
|
Loading…
Reference in a new issue