1 | package fr.sii.ogham.html.inliner.impl.regexp; | |
2 | ||
3 | import static fr.sii.ogham.core.util.HtmlUtils.CSS_IMAGE_PROPERTIES_PATTERN; | |
4 | import static fr.sii.ogham.core.util.HtmlUtils.CSS_URL_FUNC_PATTERN; | |
5 | import static fr.sii.ogham.html.inliner.impl.regexp.CssImageInlinerConstants.INLINED_URL_FUNC; | |
6 | import static fr.sii.ogham.html.inliner.impl.regexp.CssImageInlinerConstants.INLINE_MODE_PROPERTY; | |
7 | ||
8 | import java.util.List; | |
9 | import java.util.function.Function; | |
10 | import java.util.regex.Matcher; | |
11 | import java.util.regex.Pattern; | |
12 | ||
13 | import org.slf4j.Logger; | |
14 | import org.slf4j.LoggerFactory; | |
15 | ||
16 | import fr.sii.ogham.html.inliner.ImageResource; | |
17 | import fr.sii.ogham.html.inliner.impl.regexp.CssImageInlinerConstants.InlineMode; | |
18 | ||
19 | /** | |
20 | * Helper class that factorizes code for classes that are using inliners. | |
21 | * | |
22 | * @author Aurélien Baudet | |
23 | * | |
24 | */ | |
25 | public final class CssImageInlineUtils { | |
26 | private static final Logger LOG = LoggerFactory.getLogger(CssImageInlineUtils.class); | |
27 | ||
28 | private static final String QUOTE_ENTITY = """; | |
29 | private static final String QUOTE_TEMP_ESCAPE = ""__semicolon__"; | |
30 | private static final Pattern ESCAPE_QUOTE_ENTITIES = Pattern.compile(Pattern.quote(QUOTE_ENTITY), Pattern.CASE_INSENSITIVE); | |
31 | private static final Pattern UNESCAPE_QUOTE_ENTITIES = Pattern.compile(Pattern.quote(QUOTE_TEMP_ESCAPE), Pattern.CASE_INSENSITIVE); | |
32 | private static final Pattern RULE_START = Pattern.compile("(?<rulestart>[{])|(?<style>(?<quote>['\"])\\s*=\\s*elyts)", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE); | |
33 | private static final Pattern INLINE_PROPERTY_PATTERN = Pattern.compile("(?<property>(?<propertyname>" + Pattern.quote(INLINE_MODE_PROPERTY) + ")\\s*:)(?<value>[^;}>]+)\\s*;?", | |
34 | Pattern.MULTILINE | Pattern.DOTALL | Pattern.CASE_INSENSITIVE); | |
35 | private static final Pattern INLINE_PROPERTY_MODE_PATTERN = Pattern.compile("\\s*((?<imageurl>[^=]+)=(?<specificmode>[^=\"';\\s]+))|(?<globalmode>[^=;\"'\\s]+)"); | |
36 | private static final Pattern INLINED_URL_PATTERN = Pattern.compile(Pattern.quote(INLINED_URL_FUNC)); | |
37 | ||
38 | /** | |
39 | * Search for all images included by CSS properties using {@code url()} | |
40 | * (either defined in CSS rules or style attributes). | |
41 | * | |
42 | * <p> | |
43 | * For each matched URL, it delegates the replacement value to | |
44 | * {@code inlineHandler} parameter. The HTML content is updated with the new | |
45 | * URL if the image points to a local image and the handler corresponds to | |
46 | * the inline mode. | |
47 | * | |
48 | * <p> | |
49 | * The inline mode can be specified globally (default mode if none is | |
50 | * specified), per CSS rule or per image using | |
51 | * {@link CssImageInlinerConstants#INLINE_MODE_PROPERTY}. | |
52 | * | |
53 | * | |
54 | * @param htmlContent | |
55 | * the HTML content that may include CSS properties that points | |
56 | * to images that need to be inlined | |
57 | * @param images | |
58 | * the images to inline | |
59 | * @param mode | |
60 | * the inline mode | |
61 | * @param inlineHandler | |
62 | * the handler that provides the URL replacement | |
63 | * @return the updated HTML | |
64 | */ | |
65 | public static String inline(String htmlContent, List<ImageResource> images, InlineMode mode, Function<CssImageDeclaration, String> inlineHandler) { | |
66 | StringBuffer sb = new StringBuffer(); | |
67 | String escapedHtml = escapeQuoteEntities(htmlContent); | |
68 | Matcher propertyDeclarationMatcher = CSS_IMAGE_PROPERTIES_PATTERN.matcher(escapedHtml); | |
69 |
3
1. inline : negated conditional → NO_COVERAGE 2. inline : negated conditional → KILLED 3. inline : negated conditional → KILLED |
while (propertyDeclarationMatcher.find()) { |
70 | String value = propertyDeclarationMatcher.group("value"); | |
71 | Matcher urlMatcher = CSS_URL_FUNC_PATTERN.matcher(value); | |
72 | StringBuffer newValue = new StringBuffer(); | |
73 |
3
1. inline : negated conditional → NO_COVERAGE 2. inline : negated conditional → KILLED 3. inline : negated conditional → KILLED |
while (urlMatcher.find()) { |
74 | boolean inlined = true; | |
75 | MatchedUrl matchedUrl = getUrl(urlMatcher); | |
76 | String newUrl = getInlinedUrl(escapedHtml, propertyDeclarationMatcher, matchedUrl, images, mode, inlineHandler); | |
77 | // if no new url => use old one | |
78 |
3
1. inline : negated conditional → NO_COVERAGE 2. inline : negated conditional → KILLED 3. inline : negated conditional → KILLED |
if (newUrl == null) { |
79 | newUrl = matchedUrl.getUrl(); | |
80 | inlined = false; | |
81 | } | |
82 | urlMatcher.appendReplacement(newValue, | |
83 | Matcher.quoteReplacement(markAsInlned(inlined, urlMatcher.group("start")) + matchedUrl.getDelim() + newUrl + matchedUrl.getDelim() + urlMatcher.group("end"))); | |
84 | } | |
85 | urlMatcher.appendTail(newValue); | |
86 | propertyDeclarationMatcher.appendReplacement(sb, Matcher.quoteReplacement(propertyDeclarationMatcher.group("property") + newValue.toString())); | |
87 | } | |
88 | propertyDeclarationMatcher.appendTail(sb); | |
89 |
3
1. inline : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::inline → NO_COVERAGE 2. inline : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::inline → KILLED 3. inline : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::inline → KILLED |
return unescapeQuoteEntities(sb.toString()); |
90 | } | |
91 | ||
92 | /** | |
93 | * Checks if inlining mode is allowed on the provided element. | |
94 | * | |
95 | * @param img | |
96 | * the image element to check if the actual inlining mode is | |
97 | * allowed | |
98 | * @param mode | |
99 | * the actual mode | |
100 | * @return true if this mode is allowed, false otherwise | |
101 | */ | |
102 | @SuppressWarnings("squid:S1126") | |
103 | private static boolean isInlineModeAllowed(CssImageDeclaration img, InlineMode mode) { | |
104 | // if already inlined, the regexp won't match so don't need to | |
105 | // check if skipped here | |
106 | ||
107 | // if inline mode defined but not the wanted mode => reject | |
108 |
6
1. isInlineModeAllowed : negated conditional → NO_COVERAGE 2. isInlineModeAllowed : negated conditional → NO_COVERAGE 3. isInlineModeAllowed : negated conditional → KILLED 4. isInlineModeAllowed : negated conditional → KILLED 5. isInlineModeAllowed : negated conditional → KILLED 6. isInlineModeAllowed : negated conditional → KILLED |
if (img.getMode() != null && !mode.is(img.getMode())) { |
109 |
3
1. isInlineModeAllowed : replaced boolean return with true for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::isInlineModeAllowed → NO_COVERAGE 2. isInlineModeAllowed : replaced boolean return with true for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::isInlineModeAllowed → KILLED 3. isInlineModeAllowed : replaced boolean return with true for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::isInlineModeAllowed → KILLED |
return false; |
110 | } | |
111 | // if inline mode defined and matches the wanted mode => allow | |
112 | // if no inline mode defined => allow (any mode allowed) | |
113 |
3
1. isInlineModeAllowed : replaced boolean return with false for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::isInlineModeAllowed → NO_COVERAGE 2. isInlineModeAllowed : replaced boolean return with false for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::isInlineModeAllowed → KILLED 3. isInlineModeAllowed : replaced boolean return with false for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::isInlineModeAllowed → KILLED |
return true; |
114 | } | |
115 | ||
116 | /** | |
117 | * Remove properties that are used only by Ogham: | |
118 | * <ul> | |
119 | * <li>{@link CssImageInlinerConstants#INLINE_MODE_PROPERTY}</li> | |
120 | * <li>{@link CssImageInlinerConstants#INLINED_URL_FUNC}</li> | |
121 | * </ul> | |
122 | * | |
123 | * @param html | |
124 | * the html to clean | |
125 | * @return the cleaned html | |
126 | */ | |
127 | public static String removeOghamProperties(String html) { | |
128 | String cleaned = html; | |
129 | cleaned = INLINED_URL_PATTERN.matcher(cleaned).replaceAll("url"); | |
130 | cleaned = INLINE_PROPERTY_PATTERN.matcher(cleaned).replaceAll(""); | |
131 |
3
1. removeOghamProperties : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::removeOghamProperties → NO_COVERAGE 2. removeOghamProperties : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::removeOghamProperties → KILLED 3. removeOghamProperties : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::removeOghamProperties → KILLED |
return cleaned; |
132 | } | |
133 | ||
134 | private static String getInlinedUrl(String htmlContent, Matcher propertyDeclarationMatcher, MatchedUrl matchedUrl, List<ImageResource> images, InlineMode mode, | |
135 | Function<CssImageDeclaration, String> inlineHandler) { | |
136 | String url = matchedUrl.getUrl(); | |
137 | ImageResource image = getImage(url, images); | |
138 | // url may match external url => simply skip it | |
139 |
3
1. getInlinedUrl : negated conditional → NO_COVERAGE 2. getInlinedUrl : negated conditional → KILLED 3. getInlinedUrl : negated conditional → KILLED |
if (image == null) { |
140 | LOG.debug("Skipping {}", url); | |
141 |
3
1. getInlinedUrl : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::getInlinedUrl → NO_COVERAGE 2. getInlinedUrl : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::getInlinedUrl → KILLED 3. getInlinedUrl : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::getInlinedUrl → KILLED |
return null; |
142 | } | |
143 | String enclosingCssRule = getEnclosingCssRule(htmlContent, propertyDeclarationMatcher); | |
144 | CssImageDeclaration imageDeclaration = new CssImageDeclaration(matchedUrl, getInlineProperty(enclosingCssRule, matchedUrl), image); | |
145 |
3
1. getInlinedUrl : negated conditional → NO_COVERAGE 2. getInlinedUrl : negated conditional → KILLED 3. getInlinedUrl : negated conditional → KILLED |
if (!isInlineModeAllowed(imageDeclaration, mode)) { |
146 |
3
1. getInlinedUrl : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::getInlinedUrl → NO_COVERAGE 2. getInlinedUrl : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::getInlinedUrl → KILLED 3. getInlinedUrl : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::getInlinedUrl → KILLED |
return null; |
147 | } | |
148 |
3
1. getInlinedUrl : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::getInlinedUrl → NO_COVERAGE 2. getInlinedUrl : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::getInlinedUrl → KILLED 3. getInlinedUrl : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::getInlinedUrl → KILLED |
return inlineHandler.apply(imageDeclaration); |
149 | } | |
150 | ||
151 | private static MatchedUrl getUrl(Matcher urlMatcher) { | |
152 | String url = urlMatcher.group("unquotedurl"); | |
153 | String delim = ""; | |
154 |
6
1. getUrl : negated conditional → NO_COVERAGE 2. getUrl : negated conditional → NO_COVERAGE 3. getUrl : negated conditional → KILLED 4. getUrl : negated conditional → KILLED 5. getUrl : negated conditional → KILLED 6. getUrl : negated conditional → KILLED |
if (url != null && url.contains(QUOTE_TEMP_ESCAPE)) { |
155 | url = removeQuoteEntities(url); | |
156 | delim = QUOTE_TEMP_ESCAPE; | |
157 | } | |
158 |
3
1. getUrl : negated conditional → NO_COVERAGE 2. getUrl : negated conditional → KILLED 3. getUrl : negated conditional → KILLED |
if (url == null) { |
159 | url = urlMatcher.group("singlequotedurl"); | |
160 | delim = "'"; | |
161 | } | |
162 |
3
1. getUrl : negated conditional → NO_COVERAGE 2. getUrl : negated conditional → KILLED 3. getUrl : negated conditional → KILLED |
if (url == null) { |
163 | url = urlMatcher.group("doublequotedurl"); | |
164 | delim = "\""; | |
165 | } | |
166 |
3
1. getUrl : replaced return value with null for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::getUrl → NO_COVERAGE 2. getUrl : replaced return value with null for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::getUrl → KILLED 3. getUrl : replaced return value with null for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::getUrl → KILLED |
return new MatchedUrl(url, delim); |
167 | } | |
168 | ||
169 | private static ImageResource getImage(String url, List<ImageResource> images) { | |
170 | // @formatter:off | |
171 |
3
1. getImage : replaced return value with null for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::getImage → NO_COVERAGE 2. getImage : replaced return value with null for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::getImage → KILLED 3. getImage : replaced return value with null for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::getImage → KILLED |
return images.stream() |
172 |
6
1. lambda$getImage$0 : replaced boolean return with false for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::lambda$getImage$0 → NO_COVERAGE 2. lambda$getImage$0 : replaced boolean return with true for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::lambda$getImage$0 → NO_COVERAGE 3. lambda$getImage$0 : replaced boolean return with false for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::lambda$getImage$0 → KILLED 4. lambda$getImage$0 : replaced boolean return with false for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::lambda$getImage$0 → KILLED 5. lambda$getImage$0 : replaced boolean return with true for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::lambda$getImage$0 → KILLED 6. lambda$getImage$0 : replaced boolean return with true for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::lambda$getImage$0 → KILLED |
.filter(i -> url.equals(i.getSrcUrl())) |
173 | .findFirst() | |
174 | .orElse(null); | |
175 | // @formatter:on | |
176 | } | |
177 | ||
178 | private static String unescapeQuoteEntities(String str) { | |
179 |
3
1. unescapeQuoteEntities : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::unescapeQuoteEntities → NO_COVERAGE 2. unescapeQuoteEntities : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::unescapeQuoteEntities → KILLED 3. unescapeQuoteEntities : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::unescapeQuoteEntities → KILLED |
return UNESCAPE_QUOTE_ENTITIES.matcher(str).replaceAll(QUOTE_ENTITY); |
180 | } | |
181 | ||
182 | private static String removeQuoteEntities(String url) { | |
183 |
3
1. removeQuoteEntities : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::removeQuoteEntities → NO_COVERAGE 2. removeQuoteEntities : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::removeQuoteEntities → KILLED 3. removeQuoteEntities : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::removeQuoteEntities → KILLED |
return UNESCAPE_QUOTE_ENTITIES.matcher(url).replaceAll(""); |
184 | } | |
185 | ||
186 | private static String escapeQuoteEntities(String htmlContent) { | |
187 |
3
1. escapeQuoteEntities : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::escapeQuoteEntities → NO_COVERAGE 2. escapeQuoteEntities : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::escapeQuoteEntities → KILLED 3. escapeQuoteEntities : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::escapeQuoteEntities → KILLED |
return ESCAPE_QUOTE_ENTITIES.matcher(htmlContent).replaceAll(QUOTE_TEMP_ESCAPE); |
188 | } | |
189 | ||
190 | private static String getEnclosingCssRule(String htmlContent, Matcher propertyDeclarationMatcher) { | |
191 | String untilPropertyDeclaration = htmlContent.substring(0, propertyDeclarationMatcher.start()); | |
192 | Matcher m = RULE_START.matcher(new StringBuilder(untilPropertyDeclaration).reverse()); | |
193 | int ruleStart = -1; | |
194 | char endChar = '}'; | |
195 |
3
1. getEnclosingCssRule : negated conditional → NO_COVERAGE 2. getEnclosingCssRule : negated conditional → KILLED 3. getEnclosingCssRule : negated conditional → KILLED |
if (m.find()) { |
196 |
2
1. getEnclosingCssRule : Replaced integer subtraction with addition → SURVIVED 2. getEnclosingCssRule : Replaced integer subtraction with addition → NO_COVERAGE |
ruleStart = untilPropertyDeclaration.length() - m.start(); |
197 |
3
1. getEnclosingCssRule : negated conditional → NO_COVERAGE 2. getEnclosingCssRule : negated conditional → KILLED 3. getEnclosingCssRule : negated conditional → KILLED |
if (m.group("style") != null) { |
198 | endChar = m.group("quote").charAt(0); | |
199 | } | |
200 | } | |
201 |
3
1. getEnclosingCssRule : negated conditional → NO_COVERAGE 2. getEnclosingCssRule : negated conditional → KILLED 3. getEnclosingCssRule : negated conditional → KILLED |
if (ruleStart == -1) { |
202 | // @formatter:off | |
203 | throw new IllegalStateException("Inlining of CSS images (through either background, list-style, cursor, ...) " | |
204 | + "can't be performed safely because we can't determine the beginning of the enclosing CSS rule declaration.\n" | |
205 | + "\n" | |
206 | + "[ CSS property]="+propertyDeclarationMatcher.group()+"\n" | |
207 | + "[text before CSS property]="+untilPropertyDeclaration+"\n\n" | |
208 | + "can't find either { character that declares the beginning of a CSS rule " | |
209 | + "or style= that declares the beginning of CSS styles on an HTML tag"); | |
210 | // @formatter:on | |
211 | } | |
212 | int ruleEnd = htmlContent.indexOf(endChar, propertyDeclarationMatcher.start()); | |
213 |
3
1. getEnclosingCssRule : negated conditional → NO_COVERAGE 2. getEnclosingCssRule : negated conditional → KILLED 3. getEnclosingCssRule : negated conditional → KILLED |
if (ruleEnd == -1) { |
214 | // @formatter:off | |
215 | throw new IllegalStateException("Inlining of CSS images (through either background, list-style, cursor, ...) " | |
216 | + "can't be performed safely because we can't determine the end of the enclosing CSS rule declaration.\n" | |
217 | + "\n" | |
218 | + "[ CSS property]="+propertyDeclarationMatcher.group()+"\n" | |
219 | + "[text after CSS property]="+htmlContent.substring(propertyDeclarationMatcher.end())+"\n\n" | |
220 | + "can't find either } character that declares the end of a CSS rule " | |
221 | + "or "+endChar+" that declares the end of CSS styles on an HTML tag"); | |
222 | // @formatter:on | |
223 | } | |
224 |
3
1. getEnclosingCssRule : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::getEnclosingCssRule → NO_COVERAGE 2. getEnclosingCssRule : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::getEnclosingCssRule → KILLED 3. getEnclosingCssRule : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::getEnclosingCssRule → KILLED |
return htmlContent.substring(ruleStart, ruleEnd); |
225 | } | |
226 | ||
227 | private static String getInlineProperty(String enclosingCssRule, MatchedUrl matchedUrl) { | |
228 | Matcher m = INLINE_PROPERTY_PATTERN.matcher(enclosingCssRule); | |
229 |
3
1. getInlineProperty : negated conditional → NO_COVERAGE 2. getInlineProperty : negated conditional → KILLED 3. getInlineProperty : negated conditional → KILLED |
if (m.find()) { |
230 | String modes = m.group("value"); | |
231 | Matcher imageModeMatcher = INLINE_PROPERTY_MODE_PATTERN.matcher(modes); | |
232 | String globalMode = null; | |
233 |
3
1. getInlineProperty : negated conditional → NO_COVERAGE 2. getInlineProperty : negated conditional → KILLED 3. getInlineProperty : negated conditional → KILLED |
while (imageModeMatcher.find()) { |
234 | String specificInlineModeUrl = imageModeMatcher.group("imageurl"); | |
235 | // specific inline mode | |
236 |
3
1. getInlineProperty : negated conditional → NO_COVERAGE 2. getInlineProperty : negated conditional → KILLED 3. getInlineProperty : negated conditional → KILLED |
if (isInlineModeForImage(specificInlineModeUrl, matchedUrl)) { |
237 |
2
1. getInlineProperty : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::getInlineProperty → NO_COVERAGE 2. getInlineProperty : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::getInlineProperty → KILLED |
return imageModeMatcher.group("specificmode"); |
238 | } | |
239 | // if global mode defined | |
240 | String global = imageModeMatcher.group("globalmode"); | |
241 |
6
1. getInlineProperty : negated conditional → NO_COVERAGE 2. getInlineProperty : negated conditional → NO_COVERAGE 3. getInlineProperty : negated conditional → KILLED 4. getInlineProperty : negated conditional → KILLED 5. getInlineProperty : negated conditional → KILLED 6. getInlineProperty : negated conditional → KILLED |
if (global != null && globalMode == null) { |
242 | globalMode = global; | |
243 | } | |
244 | } | |
245 | // @formatter:off | |
246 | // return either: | |
247 | // - globalMode => global mode for all images included in the CSS rule | |
248 | // - null => use default mode | |
249 | // @formatter:on | |
250 |
3
1. getInlineProperty : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::getInlineProperty → NO_COVERAGE 2. getInlineProperty : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::getInlineProperty → KILLED 3. getInlineProperty : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::getInlineProperty → KILLED |
return globalMode; |
251 | } | |
252 |
3
1. getInlineProperty : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::getInlineProperty → NO_COVERAGE 2. getInlineProperty : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::getInlineProperty → KILLED 3. getInlineProperty : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::getInlineProperty → KILLED |
return null; |
253 | } | |
254 | ||
255 | private static boolean isInlineModeForImage(String inlineUrl, MatchedUrl matchedUrl) { | |
256 |
3
1. isInlineModeForImage : negated conditional → NO_COVERAGE 2. isInlineModeForImage : negated conditional → KILLED 3. isInlineModeForImage : negated conditional → KILLED |
if (inlineUrl == null) { |
257 |
3
1. isInlineModeForImage : replaced boolean return with true for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::isInlineModeForImage → NO_COVERAGE 2. isInlineModeForImage : replaced boolean return with true for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::isInlineModeForImage → KILLED 3. isInlineModeForImage : replaced boolean return with true for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::isInlineModeForImage → KILLED |
return false; |
258 | } | |
259 |
4
1. isInlineModeForImage : replaced boolean return with false for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::isInlineModeForImage → NO_COVERAGE 2. isInlineModeForImage : replaced boolean return with true for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::isInlineModeForImage → NO_COVERAGE 3. isInlineModeForImage : replaced boolean return with false for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::isInlineModeForImage → KILLED 4. isInlineModeForImage : replaced boolean return with true for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::isInlineModeForImage → KILLED |
return matchedUrl.getUrl().contains(inlineUrl); |
260 | } | |
261 | ||
262 | private static String markAsInlned(boolean inlined, String value) { | |
263 |
3
1. markAsInlned : negated conditional → SURVIVED 2. markAsInlned : negated conditional → NO_COVERAGE 3. markAsInlned : negated conditional → KILLED |
if (inlined) { |
264 |
3
1. markAsInlned : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::markAsInlned → NO_COVERAGE 2. markAsInlned : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::markAsInlned → KILLED 3. markAsInlned : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::markAsInlned → KILLED |
return value.replace("url", INLINED_URL_FUNC); |
265 | } | |
266 |
3
1. markAsInlned : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::markAsInlned → NO_COVERAGE 2. markAsInlned : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::markAsInlned → KILLED 3. markAsInlned : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlineUtils::markAsInlned → KILLED |
return value; |
267 | } | |
268 | ||
269 | private CssImageInlineUtils() { | |
270 | super(); | |
271 | } | |
272 | } | |
Mutations | ||
69 |
1.1 2.2 3.3 |
|
73 |
1.1 2.2 3.3 |
|
78 |
1.1 2.2 3.3 |
|
89 |
1.1 2.2 3.3 |
|
108 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
109 |
1.1 2.2 3.3 |
|
113 |
1.1 2.2 3.3 |
|
131 |
1.1 2.2 3.3 |
|
139 |
1.1 2.2 3.3 |
|
141 |
1.1 2.2 3.3 |
|
145 |
1.1 2.2 3.3 |
|
146 |
1.1 2.2 3.3 |
|
148 |
1.1 2.2 3.3 |
|
154 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
158 |
1.1 2.2 3.3 |
|
162 |
1.1 2.2 3.3 |
|
166 |
1.1 2.2 3.3 |
|
171 |
1.1 2.2 3.3 |
|
172 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
179 |
1.1 2.2 3.3 |
|
183 |
1.1 2.2 3.3 |
|
187 |
1.1 2.2 3.3 |
|
195 |
1.1 2.2 3.3 |
|
196 |
1.1 2.2 |
|
197 |
1.1 2.2 3.3 |
|
201 |
1.1 2.2 3.3 |
|
213 |
1.1 2.2 3.3 |
|
224 |
1.1 2.2 3.3 |
|
229 |
1.1 2.2 3.3 |
|
233 |
1.1 2.2 3.3 |
|
236 |
1.1 2.2 3.3 |
|
237 |
1.1 2.2 |
|
241 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
250 |
1.1 2.2 3.3 |
|
252 |
1.1 2.2 3.3 |
|
256 |
1.1 2.2 3.3 |
|
257 |
1.1 2.2 3.3 |
|
259 |
1.1 2.2 3.3 4.4 |
|
263 |
1.1 2.2 3.3 |
|
264 |
1.1 2.2 3.3 |
|
266 |
1.1 2.2 3.3 |