Commit 1930099a authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Belcard isn't supposed to escape/unescape URIs, expect already escaped value +...

Belcard isn't supposed to escape/unescape URIs, expect already escaped value + edited grammar to allow IPv6 SIP URIs in URI
parent 68f1e982
......@@ -46,15 +46,10 @@ namespace belcard {
};
class BelCardImpp : public BelCardProperty {
private:
std::string _escaped_value;
public:
BELCARD_PUBLIC static std::shared_ptr<BelCardImpp> parse(const std::string& input);
BELCARD_PUBLIC static void setHandlerAndCollectors(belr::Parser<std::shared_ptr<BelCardGeneric>> *parser);
BELCARD_PUBLIC void setValue(const std::string &value) override;
BELCARD_PUBLIC void serialize(std::ostream &output) const override;
BELCARD_PUBLIC BelCardImpp();
};
......
......@@ -85,36 +85,6 @@ BelCardImpp::BelCardImpp() : BelCardProperty() {
setName("IMPP");
}
void BelCardImpp::setValue(const string &value) {
bctbx_noescape_rules_t uri = {0};
bctbx_noescape_rules_add_alfanums(uri);
bctbx_noescape_rules_add_list(uri, ":@.-_~%!$&'()*+,;=");
// Escape characters if required
char * escaped_value = bctbx_escape(value.c_str(), uri);
_escaped_value = string(escaped_value);
bctbx_free(escaped_value);
// Unescape previously escaped characters
char * unescaped_value = bctbx_unescaped_string(value.c_str());
string new_value = string(unescaped_value);
bctbx_free(unescaped_value);
BelCardProperty::setValue(new_value);
}
void BelCardImpp::serialize(ostream& output) const {
if (getGroup().length() > 0) {
output << getGroup() << ".";
}
output << getName();
for (auto it = getParams().begin(); it != getParams().end(); ++it) {
output << ";" << (**it);
}
output << ":" << _escaped_value << "\r\n";
}
shared_ptr<BelCardLang> BelCardLang::parse(const string& input) {
return BelCardProperty::parseProperty<BelCardLang>("LANG", input);
}
......
No preview for this file type
......@@ -408,7 +408,8 @@ path-rootless = segment-nz *( "/" segment )
path-empty = [pchar]
segment = *pchar
segment-nz = 1*pchar
segment-nz = 1*( pchar / "[" / "]" )
; to be compatible with IPv6 SIP URIs
segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" )
; non-zero-length segment without any colon ":"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment