Package org.xwiki.validator

Examples of org.xwiki.validator.ValidationError


    @Override
    public List<ValidationError> validate()
    {
        clear();
        if (this.document.size() == 0 && !this.shouldBeEmpty) {
            this.errors.add(new ValidationError(Type.WARNING, 0, 0, "Unexpected empty response"));
        }
        if (this.document.size() > 0 && this.shouldBeEmpty) {
            this.errors.add(new ValidationError(Type.WARNING, 0, 0, "Unexpected non-empty content: \"" + getContent() + "\""));
        }
        int lineNr = 1;
        for (String line : this.document) {
            checkStringDelimiters(line, lineNr);
            checkTagDelimiter(line, lineNr, TEST_LT, "Unescaped < character");
            checkTagDelimiter(line, lineNr, TEST_GT, "Unescaped > character");

            int idx;
            if ((idx = line.indexOf("Error while parsing velocity page")) >= 0) {
                this.errors.add(new ValidationError(Type.WARNING, lineNr, idx,
                    "Parse error in the response. The template was not evaluated correctly."));
            }
            if ((idx = line.indexOf("org.xwiki.rendering.macro.MacroExecutionException")) >= 0) {
                this.errors.add(new ValidationError(Type.WARNING, lineNr, idx,
                    "Macro execution exception in the response."));
            }
            if ((idx = line.indexOf("Wrapped Exception: unexpected char:")) >= 0) {
                this.errors.add(new ValidationError(Type.WARNING, lineNr, idx, "Possible SQL error trace."));
            }
            // TODO also check \ for JavaScript
            // TODO check for overescaping
            lineNr++;
        }
View Full Code Here


        // NOTE this method produces false NEGATIVES if JavaScript escaping is used where XML/URL escaping is needed
        int idx = 0;
        while ((idx = line.indexOf(testMatch, idx)) >= 0) {
            // avoid false positives caused by JavaScript escaping
            if (!isJavascriptEscaped(line, testMatch, idx)) {
                this.errors.add(new ValidationError(Type.ERROR, lineNr, idx, errorMessage));
            }
            idx++;
        }
    }
View Full Code Here

        int idx = 0;
        while ((idx = line.indexOf(TEST_APOS, idx)) >= 0) {
            // ignore if quote was not escaped either
            int expected_idx = idx - offset;
            if (expected_idx < 0 || line.indexOf(TEST_QUOT, expected_idx) != expected_idx) {
                this.errors.add(new ValidationError(Type.WARNING, lineNr, idx, "Unescaped ' character"));
            }
            idx++;
        }
        idx = 0;
        while ((idx = line.indexOf(TEST_QUOT, idx)) >= 0) {
            // ignore if apostrophe was not escaped either
            int expected_idx = idx + offset;
            if (expected_idx < 0 || line.indexOf(TEST_APOS, expected_idx) != expected_idx) {
                this.errors.add(new ValidationError(Type.WARNING, lineNr, idx, "Unescaped \" character"));
            }
            idx++;
        }
    }
View Full Code Here

            checkTagDelimiter(line, lineNr, TEST_LT, "Unescaped < character");
            checkTagDelimiter(line, lineNr, TEST_GT, "Unescaped > character");

            int idx;
            if ((idx = line.indexOf("Error while parsing velocity page")) >= 0) {
                this.errors.add(new ValidationError(Type.WARNING, lineNr, idx,
                    "Parse error in the response. The template was not evaluated correctly."));
            }
            if ((idx = line.indexOf("org.xwiki.rendering.macro.MacroExecutionException")) >= 0) {
                this.errors.add(new ValidationError(Type.WARNING, lineNr, idx,
                    "Macro execution exception in the response."));
            }
            if ((idx = line.indexOf("Wrapped Exception: unexpected char:")) >= 0) {
                this.errors.add(new ValidationError(Type.WARNING, lineNr, idx, "Possible SQL error trace."));
            }
            // TODO also check \ for JavaScript
            // TODO check for overescaping
            lineNr++;
        }
View Full Code Here

        // NOTE this method produces false NEGATIVES if JavaScript escaping is used where XML/URL escaping is needed
        int idx = 0;
        while ((idx = line.indexOf(testMatch, idx)) >= 0) {
            // avoid false positives caused by JavaScript escaping
            if (!isJavascriptEscaped(line, testMatch, idx)) {
                this.errors.add(new ValidationError(Type.ERROR, lineNr, idx, errorMessage));
            }
            idx++;
        }
    }
View Full Code Here

        int idx = 0;
        while ((idx = line.indexOf(TEST_APOS, idx)) >= 0) {
            // ignore if quote was not escaped either
            int expected_idx = idx - offset;
            if (expected_idx < 0 || line.indexOf(TEST_QUOT, expected_idx) != expected_idx) {
                this.errors.add(new ValidationError(Type.WARNING, lineNr, idx, "Unescaped ' character"));
            }
            idx++;
        }
        idx = 0;
        while ((idx = line.indexOf(TEST_QUOT, idx)) >= 0) {
            // ignore if apostrophe was not escaped either
            int expected_idx = idx + offset;
            if (expected_idx < 0 || line.indexOf(TEST_APOS, expected_idx) != expected_idx) {
                this.errors.add(new ValidationError(Type.WARNING, lineNr, idx, "Unescaped \" character"));
            }
            idx++;
        }
    }
View Full Code Here

TOP

Related Classes of org.xwiki.validator.ValidationError

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.