#include <dpl/log/log.h>
#include <dpl/fast_delegate.h>
#include <dpl/foreach.h>
+#include <dpl/scoped_ptr.h>
#include <pcrecpp.h>
#include <algorithm>
#include <string>
};
const char* const ApplicationParser::REGEXP_PACKAGE = "[0-9A-Za-z]{10}";
-const char* const ApplicationParser::REGEXP_ID = "([0-9A-Za-z]{10})\\..{2,52}";
+const char* const ApplicationParser::REGEXP_ID = "([0-9A-Za-z]{10})\\.[0-9A-Za-z]{1,52}";
const char* const ApplicationParser::REGEXP_VERSION = "\\d+\\.\\d+(\\.\\d+)?";
class SplashParser : public ElementParser
m_width = attribute.value;
} else if (attribute.name == L"height") {
m_height = attribute.value;
+ } else if (attribute.name == L"fast-open") {
+ m_fastOpen= attribute.value;
}
}
}
m_data.m_pdSrc = m_src;
m_data.m_pdWidth = m_width;
m_data.m_pdHeight = m_height;
+ m_data.m_pdFastOpen = m_fastOpen;
}
explicit PdParser(
DPL::String m_src;
DPL::String m_width;
DPL::String m_height;
+ DPL::String m_fastOpen;
bool m_properNamespace;
ConfigParserData::LiveboxInfo::BoxContentInfo& m_data;
bool m_properNamespace;
};
+class AllowNavigationParser : public ElementParser
+{
+ public:
+ AllowNavigationParser(ConfigParserData& data) :
+ ElementParser(),
+ m_data(data),
+ m_properNamespace(false)
+ {}
+
+ virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+ const DPL::String& /*name*/)
+ {
+ return &IgnoringParser::Create;
+ }
+
+ virtual void Accept(const Element& element)
+ {
+ if (element.ns == ConfigurationNamespace::TizenWebAppNamespaceName) {
+ m_properNamespace = true;
+ }
+ }
+
+ virtual void Accept(const Text& text)
+ {
+ if (m_properNamespace) {
+ m_origin = text.value;
+ }
+ }
+
+ virtual void Accept(const XmlAttribute& /*attribute*/)
+ {
+ }
+
+ virtual void Verify()
+ {
+ if (m_origin.IsNull()) {
+ LogWarning("data is empty");
+ return;
+ }
+
+ char* data = strdup(DPL::ToUTF8String(*m_origin).c_str());
+ char* ptr = strtok(data," ");
+ while (ptr != NULL) {
+ std::string origin = ptr;
+ ptr = strtok(NULL," ");
+ if(origin == "*") {
+ ConfigParserData::AllowNavigationInfo info(L"*", L"*");
+ m_data.allowNavigationInfoList.push_back(info);
+ continue;
+ }
+
+ DPL::ScopedPtr<iri_t> iri(iri_parse(origin.c_str()));
+ if (!iri->host || strlen(iri->host) == 0) {
+ // input origin should has schem and host
+ // in case of file scheme path is filled
+ // "http://"
+ LogWarning("input origin isn't verified");
+ continue;
+ }
+ DPL::String scheme = L"*";
+ if (iri->scheme && strlen(iri->scheme) != 0) {
+ scheme = DPL::FromUTF8String(iri->scheme);
+ }
+ ConfigParserData::AllowNavigationInfo info(
+ scheme,
+ DPL::FromUTF8String(iri->host));
+ m_data.allowNavigationInfoList.push_back(info);
+ }
+ free(data);
+ }
+
+ private:
+ DPL::OptionalString m_origin;
+ ConfigParserData& m_data;
+ bool m_properNamespace;
+};
+
class CspParser : public ElementParser
{
public:
bool m_multiSupport;
};
+class MetadataParser : public ElementParser
+{
+ public:
+ virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+ const DPL::String& /*name*/)
+ {
+ return &IgnoringParser::Create;
+ }
+
+ virtual void Accept(const XmlAttribute& attribute)
+ {
+ if (m_properNamespace) {
+ if (attribute.name == L"key") {
+ m_key = attribute.value;
+ } else if (attribute.name == L"value") {
+ m_value = attribute.value;
+ }
+ }
+ }
+
+ virtual void Accept(const Element& element)
+ {
+ if (element.ns == ConfigurationNamespace::TizenWebAppNamespaceName) {
+ m_properNamespace = true;
+ }
+ }
+
+ virtual void Accept(const Text& /*text*/)
+ {
+ ThrowMsg(Exception::ParseError, "param element must be empty");
+ }
+
+ virtual void Verify()
+ {
+ if (m_key.IsNull()) {
+ LogWarning("metadata element must have key attribute");
+ return;
+ }
+ NormalizeString(m_key);
+ NormalizeString(m_value);
+ ConfigParserData::Metadata metaData(*m_key, *m_value);
+ FOREACH(it, m_data.metadataList) {
+ if (!DPL::StringCompare(it->key, *m_key)) {
+ LogError("Key isn't unique");
+ return;
+ }
+ }
+ m_data.metadataList.push_back(metaData);
+ }
+
+ MetadataParser(ConfigParserData& data) :
+ ElementParser(),
+ m_data(data),
+ m_properNamespace(false)
+ {}
+
+ private:
+ DPL::OptionalString m_key;
+ DPL::OptionalString m_value;
+ ConfigParserData& m_data;
+ bool m_properNamespace;
+};
+
ElementParser::ActionFunc WidgetParser::GetElementParser(
const DPL::String& /*ns*/,
const DPL::String&
&WidgetParser::
OnCspReportOnlyElement);
#endif
+#ifdef ALLOW_NAVIGATION_ENABLED
+ m_map[L"allow-navigation"] =
+ DPL::MakeDelegate(this, &WidgetParser::OnAllowNavigationElement);
+#endif
m_map[L"account"] = DPL::MakeDelegate(this, &WidgetParser::OnAccountElement);
+ m_map[L"metadata"] = DPL::MakeDelegate(this, &WidgetParser::OnMetadataElement);
}
ElementParserPtr WidgetParser::OnNameElement()
return ElementParserPtr(new CspReportOnlyParser(m_data));
}
+ElementParserPtr WidgetParser::OnAllowNavigationElement()
+{
+ return ElementParserPtr(new AllowNavigationParser(m_data));
+}
+
ElementParserPtr WidgetParser::OnAccountElement()
{
return ElementParserPtr(new AccountParser(m_data));
}
+ElementParserPtr WidgetParser::OnMetadataElement()
+{
+ return ElementParserPtr(new MetadataParser(m_data));
+}
+
void WidgetParser::Accept(const Element& element)
{
if (element.ns != ConfigurationNamespace::W3CWidgetNamespaceName &&