Content-Security-Policy-Report-Only xml tag support
authorAndrzej Surdej <a.surdej@samsung.com>
Wed, 27 Feb 2013 13:35:25 +0000 (14:35 +0100)
committerGerrit Code Review <gerrit2@kim11>
Tue, 5 Mar 2013 15:25:52 +0000 (00:25 +0900)
[Issue#] N/A
[Problem] Report only csp policy was not supported.
[Cause] N/A
[Solution] Provided parsing and storing of csp-report-only
[Verification] Build repo and run any widget.

This commit requires: https://tizendev.org/gerrit/#/c/48887/

Change-Id: I21bbecd69775029ea205076aec0dc231879df00f

src/configuration_parser/widget_parser.cpp
src/configuration_parser/widget_parser.h

index 7703f4b..7dc58aa 100644 (file)
@@ -2161,6 +2161,51 @@ class CspParser : public ElementParser
     DPL::OptionalString m_policy;
 };
 
+class CspReportOnlyParser : public ElementParser
+{
+  public:
+    virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+                                        const DPL::String& /*name*/)
+    {
+        return &IgnoringParser::Create;
+    }
+
+    CspReportOnlyParser(ConfigParserData& data) :
+        ElementParser(),
+        m_data(data),
+        m_properNamespace(false)
+    {}
+
+    virtual void Accept(const Element& element)
+    {
+        if (element.ns == ConfigurationNamespace::TizenWebAppNamespaceName) {
+            m_properNamespace = true;
+        }
+    }
+
+    virtual void Accept(const XmlAttribute& /*attribute*/)
+    {}
+
+    virtual void Accept(const Text& text)
+    {
+        if (m_properNamespace) {
+            m_policy = text.value;
+        }
+    }
+
+    virtual void Verify()
+    {
+        if (!m_policy.IsNull()) {
+            m_data.cspPolicyReportOnly = *m_policy;
+        }
+    }
+
+  private:
+    ConfigParserData& m_data;
+    bool m_properNamespace;
+    DPL::OptionalString m_policy;
+};
+
 ElementParser::ActionFunc WidgetParser::GetElementParser(
     const DPL::String& /*ns*/,
     const DPL::String&
@@ -2219,6 +2264,10 @@ WidgetParser::WidgetParser(ConfigParserData& data) :
             this,
             &WidgetParser::
                 OnCspElement);
+    m_map[L"Content-Security-Policy-Report-Only"] = DPL::MakeDelegate(
+            this,
+            &WidgetParser::
+                OnCspReportOnlyElement);
 #endif
 }
 
@@ -2322,6 +2371,11 @@ ElementParserPtr WidgetParser::OnCspElement()
     return ElementParserPtr(new CspParser(m_data));
 }
 
+ElementParserPtr WidgetParser::OnCspReportOnlyElement()
+{
+    return ElementParserPtr(new CspReportOnlyParser(m_data));
+}
+
 void WidgetParser::Accept(const Element& element)
 {
     if (element.ns != ConfigurationNamespace::W3CWidgetNamespaceName &&
index af39afd..c8c1a2b 100644 (file)
@@ -84,6 +84,7 @@ class WidgetParser : public ElementParser
     ElementParserPtr OnCategoryElement();
     ElementParserPtr OnLiveboxElement();
     ElementParserPtr OnCspElement();
+    ElementParserPtr OnCspReportOnlyElement();
 
     virtual ActionFunc GetElementParser(const DPL::String& ns,
                                         const DPL::String& name);