This is an automated email from the ASF dual-hosted git repository.

dklco pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-app-cms.git


The following commit(s) were added to refs/heads/master by this push:
     new 9439f8f  Minor: Replacing CMS-specific HTML5Serializer with Rewriter 
1.3.0
9439f8f is described below

commit 9439f8f4e185d831b83c7d50f59a950165e5a7f7
Author: Dan Klco <[email protected]>
AuthorDate: Wed Jan 20 14:08:39 2021 -0500

    Minor: Replacing CMS-specific HTML5Serializer with Rewriter 1.3.0
---
 .../core/internal/rewriter/HTML5Serializer.java    | 182 ---------------------
 .../internal/rewriter/Html5SerializerFactory.java  |  44 -----
 feature/src/main/features/cms/dependencies.json    |   2 +-
 3 files changed, 1 insertion(+), 227 deletions(-)

diff --git 
a/core/src/main/java/org/apache/sling/cms/core/internal/rewriter/HTML5Serializer.java
 
b/core/src/main/java/org/apache/sling/cms/core/internal/rewriter/HTML5Serializer.java
deleted file mode 100644
index 214d30e..0000000
--- 
a/core/src/main/java/org/apache/sling/cms/core/internal/rewriter/HTML5Serializer.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sling.cms.core.internal.rewriter;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.sling.api.resource.Resource;
-import org.apache.sling.caconfig.resource.ConfigurationResourceResolver;
-import org.apache.sling.rewriter.ProcessingComponentConfiguration;
-import org.apache.sling.rewriter.ProcessingContext;
-import org.apache.sling.rewriter.Serializer;
-import org.xml.sax.Attributes;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-
-/**
- * Serializer for writing HTML5 compliant markup
- */
-public class HTML5Serializer implements Serializer {
-
-    private static final int CHAR_EQ = 61;
-
-    private static final int CHAR_GT = 62;
-
-    private static final int CHAR_SP = 32;
-
-    private static final int CHAR_LT = 60;
-
-    private static final Set<String> emptyTags = new HashSet<>();
-    static {
-        emptyTags.addAll(Arrays.asList("br", "area", "link", "img", "param", 
"hr", "input", "col", "base", "meta"));
-    }
-    private PrintWriter writer;
-
-    private ConfigurationResourceResolver resolver;
-
-    private Resource rewriteConfig;
-
-    public HTML5Serializer(ConfigurationResourceResolver resolver) {
-        this.resolver = resolver;
-    }
-
-    @Override
-    public void characters(char[] buffer, int offset, int length) throws 
SAXException {
-        if (length == 0) {
-            writer.flush();
-        } else {
-            writer.write(buffer, offset, length);
-        }
-    }
-
-    @Override
-    public void dispose() {
-        // Nothing required
-    }
-
-    @Override
-    public void endDocument() throws SAXException {
-        writer.flush();
-    }
-
-    @Override
-    public void endElement(String uri, String localName, String qName) throws 
SAXException {
-        if (!emptyTags.contains(localName)) {
-            writer.write("</");
-            writer.write(qName);
-            writer.write(CHAR_GT);
-        }
-    }
-
-    @Override
-    public void endPrefixMapping(String s) throws SAXException {
-        // Nothing required
-    }
-
-    @Override
-    public void ignorableWhitespace(char[] ac, int i, int j) throws 
SAXException {
-        // Nothing required
-    }
-
-    @Override
-    public void init(ProcessingContext context, 
ProcessingComponentConfiguration config) throws IOException {
-        if (context.getWriter() == null) {
-            throw new IllegalArgumentException("Failed to initialize 
HTML5Serializer, null writer specified!");
-        } else {
-            writer = context.getWriter();
-            rewriteConfig = 
resolver.getResource(context.getRequest().getResource(), "site", "rewrite");
-        }
-    }
-
-    @Override
-    public void processingInstruction(String s, String s1) throws SAXException 
{
-        // Nothing required
-    }
-
-    @Override
-    public void setDocumentLocator(Locator locator1) {
-        // Nothing required
-    }
-
-    @Override
-    public void skippedEntity(String s) throws SAXException {
-        // Nothing required
-    }
-
-    @Override
-    public void startDocument() throws SAXException {
-        writer.println(rewriteConfig.getValueMap().get("doctype", 
String.class));
-    }
-
-    @Override
-    public void startElement(String uri, String localName, String qName, 
Attributes atts) throws SAXException {
-        boolean endSlash = false;
-        writer.write(CHAR_LT);
-        writer.write(qName);
-
-        for (int i = 0; i < atts.getLength(); i++) {
-            if ("endSlash".equals(atts.getQName(i))) {
-                endSlash = true;
-            }
-            String value = atts.getValue(i);
-            if (shouldContinue(localName, atts, i)) {
-                continue;
-            }
-            writer.write(CHAR_SP);
-            writer.write(atts.getQName(i));
-
-            writer.write(CHAR_EQ);
-            writer.write('"');
-            writer.write(value);
-            writer.write('"');
-        }
-
-        if (endSlash) {
-            writer.write("/");
-        }
-        writer.write(CHAR_GT);
-    }
-
-    private boolean shouldContinue(String localName, Attributes atts, int i) {
-        if ("endSlash".equals(atts.getQName(i))) {
-            return true;
-        }
-        if ("a".equals(localName) && "shape".equals(atts.getLocalName(i))) {
-            return true;
-        }
-        if ("iframe".equals(localName)
-                && ("frameborder".equals(atts.getLocalName(i)) || 
"scrolling".equals(atts.getLocalName(i)))) {
-            return true;
-        }
-        if ("br".equals(localName) && ("clear".equals(atts.getLocalName(i)))) {
-            return true;
-        }
-        if (atts.getValue(i) == null) {
-            return true;
-        }
-        return false;
-    }
-
-    @Override
-    public void startPrefixMapping(String s, String s1) throws SAXException {
-        // Nothing required
-    }
-}
diff --git 
a/core/src/main/java/org/apache/sling/cms/core/internal/rewriter/Html5SerializerFactory.java
 
b/core/src/main/java/org/apache/sling/cms/core/internal/rewriter/Html5SerializerFactory.java
deleted file mode 100644
index ef52189..0000000
--- 
a/core/src/main/java/org/apache/sling/cms/core/internal/rewriter/Html5SerializerFactory.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sling.cms.core.internal.rewriter;
-
-import org.apache.sling.caconfig.resource.ConfigurationResourceResolver;
-import org.apache.sling.rewriter.Serializer;
-import org.apache.sling.rewriter.SerializerFactory;
-import org.osgi.framework.Constants;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Reference;
-
-/**
- * This sax serializer serializes HTML5 Compliant Markup
- */
-@Component(service = SerializerFactory.class, property = { 
Constants.SERVICE_VENDOR + "=The Apache Software Foundation",
-               "pipeline.type=html5-serializer" })
-public class Html5SerializerFactory implements SerializerFactory {
-
-       @Reference
-       private ConfigurationResourceResolver resolver;
-
-       /**
-        * @see org.apache.sling.rewriter.SerializerFactory#createSerializer()
-        */
-       @Override
-       public Serializer createSerializer() {
-               return new HTML5Serializer(resolver);
-       }
-
-}
diff --git a/feature/src/main/features/cms/dependencies.json 
b/feature/src/main/features/cms/dependencies.json
index 626b817..00da983 100644
--- a/feature/src/main/features/cms/dependencies.json
+++ b/feature/src/main/features/cms/dependencies.json
@@ -93,7 +93,7 @@
             "start-order": "15"
         },
         {
-            "id": "org.apache.sling:org.apache.sling.rewriter:1.2.2",
+            "id": "org.apache.sling:org.apache.sling.rewriter:1.3.0",
             "start-order": "15"
         },
         {

Reply via email to