Encode JSON variables in AMP article page
authorJoshua Rüsweg <ruesweg@woltlab.com>
Thu, 30 May 2019 19:31:31 +0000 (21:31 +0200)
committerJoshua Rüsweg <ruesweg@woltlab.com>
Thu, 30 May 2019 19:31:40 +0000 (21:31 +0200)
com.woltlab.wcf/templates/ampArticle.tpl

index a9979f5ce7bad813293d0ce1847a30ba0d47935e..8ca0e21537a52d8528691b0d785f285b667367ee 100644 (file)
@@ -5,21 +5,21 @@
                {
                        "@context": "http://schema.org",
                        "@type": "NewsArticle",
-                       "mainEntityOfPage": "{$regularCanonicalURL}",
-                       "headline": "{$articleContent->title}",
+                       "mainEntityOfPage": "{@$regularCanonicalURL|encodeJSON}",
+                       "headline": "{@$articleContent->title|encodeJSON}",
                        "datePublished": "{@$article->time|date:'c'}",
                        "dateModified": "{@$article->time|date:'c'}",
-                       "description": "{@$articleContent->getFormattedTeaser()}",
+                       "description": "{@$articleContent->getFormattedTeaser()|encodeJSON}",
                        "author": {
                                "@type": "Person",
-                               "name": "{$article->username}"
+                               "name": "{@$article->username|encodeJSON}"
                        },
                        "publisher": {
                                "@type": "Organization",
                                "name": "{PAGE_TITLE|language}",
                                "logo": {
                                        "@type": "ImageObject",
-                                       "url": "{$__wcf->getStyleHandler()->getStyle()->getPageLogo()}",
+                                       "url": "{@$__wcf->getStyleHandler()->getStyle()->getPageLogo()|encodeJSON}",
                                        "width": {@$__wcf->getStyleHandler()->getStyle()->getVariable('pageLogoWidth')},
                                        "height": {@$__wcf->getStyleHandler()->getStyle()->getVariable('pageLogoHeight')}
                                }
@@ -27,7 +27,7 @@
                        {if $articleContent->getImage()}
                        ,"image": {
                                "@type": "ImageObject",
-                               "url": "{$articleContent->getImage()->getThumbnailLink('large')}",
+                               "url": "{@$articleContent->getImage()->getThumbnailLink('large')|encodeJSON}",
                                "width": {@$articleContent->getImage()->getThumbnailWidth('large')},
                                "height": {@$articleContent->getImage()->getThumbnailHeight('large')}
                        }