SLING-8555 - Converter generates broken repoinit statements when package
contains type indicators for restriction

applied value extraction also on restrictions
diff --git a/src/main/java/org/apache/sling/feature/cpconverter/handlers/RepPolicyEntryHandler.java b/src/main/java/org/apache/sling/feature/cpconverter/handlers/RepPolicyEntryHandler.java
index 877fe37..dfe8126 100644
--- a/src/main/java/org/apache/sling/feature/cpconverter/handlers/RepPolicyEntryHandler.java
+++ b/src/main/java/org/apache/sling/feature/cpconverter/handlers/RepPolicyEntryHandler.java
@@ -111,18 +111,14 @@
 
                     String operation = operations.get(primaryType);
 
-                    String privileges = attributes.getValue(REP_PRIVILEGES);
-                    Matcher matcher = typeIndicatorPattern.matcher(privileges);
-                    if (matcher.matches()) {
-                        privileges = matcher.group(1);
-                    }
+                    String privileges = extractValue(attributes.getValue(REP_PRIVILEGES));
 
                     Acl acl = new Acl(operation, privileges, Paths.get(path));
 
                     acls.add(aclManager.addAcl(principalName, acl));
                 } else if (REP_RESTRICTIONS.equals(primaryType) && !acls.isEmpty()) {
                     for (String restriction : RESTRICTIONS) {
-                        String path = attributes.getValue(restriction);
+                        String path = extractValue(attributes.getValue(restriction));
 
                         if (path != null && !path.isEmpty()) {
                             acls.peek().addRestriction(restriction + ',' + path);
@@ -151,6 +147,19 @@
             return null;
         }
 
+        private static String extractValue(String expression) {
+            if (expression == null || expression.isEmpty()) {
+                return expression;
+            }
+
+            Matcher matcher = typeIndicatorPattern.matcher(expression);
+            if (matcher.matches()) {
+                return matcher.group(1);
+            }
+
+            return expression;
+        }
+
     }
 
 }
diff --git a/src/test/resources/org/apache/sling/feature/cpconverter/handlers/jcr_root/asd/public/_rep_policy.xml b/src/test/resources/org/apache/sling/feature/cpconverter/handlers/jcr_root/asd/public/_rep_policy.xml
index 8b639bb..66bb45c 100644
--- a/src/test/resources/org/apache/sling/feature/cpconverter/handlers/jcr_root/asd/public/_rep_policy.xml
+++ b/src/test/resources/org/apache/sling/feature/cpconverter/handlers/jcr_root/asd/public/_rep_policy.xml
@@ -23,7 +23,7 @@
             rep:privileges="{Name}[jcr:read,rep:write,rep:indexDefinitionManagement]">
         <rep:restrictions
                 jcr:primaryType="rep:Restrictions"
-                rep:glob="*/oak:index/*"/>
+                rep:glob="{Name}[*/oak:index/*]"/>
     </allow0>
     <allow1
             jcr:primaryType="rep:GrantACE"