|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| XWikiScannerUtil | Line # 26 | 35 | 0% | 15 | 6 | 90.2% |
0.90163934
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (27) | |||
| Result | |||
|
0.90163934
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.90163934
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.90163934
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.21311475
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.21311475
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.21311475
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.21311475
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.21311475
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.21311475
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.21311475
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.21311475
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.21311475
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.21311475
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.21311475
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.21311475
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.21311475
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.21311475
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.21311475
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.21311475
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.21311475
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.21311475
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.21311475
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.21311475
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.21311475
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.21311475
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.21311475
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
|
0.21311475
|
org.xwiki.rendering.test.integration.RenderingTest.execute
org.xwiki.rendering.test.integration.RenderingTest.execute
|
1 PASS | |
| 1 | /* | |
| 2 | * See the NOTICE file distributed with this work for additional | |
| 3 | * information regarding copyright ownership. | |
| 4 | * | |
| 5 | * This is free software; you can redistribute it and/or modify it | |
| 6 | * under the terms of the GNU Lesser General Public License as | |
| 7 | * published by the Free Software Foundation; either version 2.1 of | |
| 8 | * the License, or (at your option) any later version. | |
| 9 | * | |
| 10 | * This software is distributed in the hope that it will be useful, | |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | * Lesser General Public License for more details. | |
| 14 | * | |
| 15 | * You should have received a copy of the GNU Lesser General Public | |
| 16 | * License along with this software; if not, write to the Free | |
| 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
| 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
| 19 | */ | |
| 20 | package org.xwiki.rendering.wikimodel.xwiki.xwiki20; | |
| 21 | ||
| 22 | /** | |
| 23 | * @version $Id: baf1894b3da110be4a300f0135bd2e96a0757ef9 $ | |
| 24 | * @since 4.0M1 | |
| 25 | */ | |
| 26 | public class XWikiScannerUtil | |
| 27 | { | |
| 28 | public static final char ESCAPECHAR = '~'; | |
| 29 | ||
| 30 | /** | |
| 31 | * To have }}} or {{{ inside inline block we need to escape it in some | |
| 32 | * condition. This method remove this escaping to send the correct text to | |
| 33 | * the event. | |
| 34 | */ | |
| 35 | 115 |
public static String unescapeVerbatim(String content) |
| 36 | { | |
| 37 | 115 | StringBuffer unescapedContent = new StringBuffer(); |
| 38 | ||
| 39 | 115 | boolean escaped = false; |
| 40 | 115 | char[] buff = content.toCharArray(); |
| 41 | 709 | for (int i = 0; i < buff.length; ++i) { |
| 42 | 594 | if (!escaped) { |
| 43 | 553 | if (buff[i] == '~') { |
| 44 | 41 | escaped = true; |
| 45 | 41 | continue; |
| 46 | } | |
| 47 | } else { | |
| 48 | ? | if (i < (i = matchVerbatimSyntax(buff, i, '{'))) { |
| 49 | 17 | unescapedContent.append("{{{"); |
| 50 | 17 | escaped = false; |
| 51 | 17 | continue; |
| 52 | ? | } else if (i < (i = matchVerbatimSyntax(buff, i, '}'))) { |
| 53 | 19 | unescapedContent.append("}}}"); |
| 54 | 19 | escaped = false; |
| 55 | 19 | continue; |
| 56 | } else { | |
| 57 | 5 | unescapedContent.append('~'); |
| 58 | } | |
| 59 | ||
| 60 | 5 | escaped = false; |
| 61 | } | |
| 62 | ||
| 63 | 517 | unescapedContent.append(buff[i]); |
| 64 | } | |
| 65 | ||
| 66 | 115 | return unescapedContent.toString(); |
| 67 | } | |
| 68 | ||
| 69 | 65 |
private static int matchVerbatimSyntax(char buff[], int currentIndex, |
| 70 | char syntax) | |
| 71 | { | |
| 72 | ||
| 73 | 65 | int i = currentIndex; |
| 74 | 65 | boolean escaped = true; |
| 75 | 169 | for (int j = 0; i < buff.length && j < 3; ++i) { |
| 76 | 169 | if (!escaped) { |
| 77 | 72 | if (buff[i] == syntax) { |
| 78 | 40 | if (++j == 3) { |
| 79 | 20 | return i; |
| 80 | } | |
| 81 | 32 | } else if (buff[i] == '~') { |
| 82 | 32 | escaped = true; |
| 83 | } | |
| 84 | } else { | |
| 85 | 97 | if (buff[i] == syntax) { |
| 86 | 68 | if (++j == 3) { |
| 87 | 16 | return i; |
| 88 | } | |
| 89 | } else { | |
| 90 | 29 | break; |
| 91 | } | |
| 92 | ||
| 93 | 52 | escaped = false; |
| 94 | } | |
| 95 | } | |
| 96 | ||
| 97 | 29 | return currentIndex; |
| 98 | } | |
| 99 | } | |
|
||||||||||||