I don't see it checking by default. So I should use <regexmatch> specifically to detect the invalid characters, right? Could you give an example?

asked 21 Nov '12, 19:31

gt8967884's gravatar image

gt8967884
116747678
accept rate: 12%


This depends on what your invalid characters are. Is this caused by the application not handling certain letters (i.e. Unicode) in path correctly. If so, the recommended approach is to create a regular expression that throws away invalid values:

<throwError>
    <text>Invalid value</text>
    <ruleList>
        <regExMatch>
            <logic>matches</logic>
            <pattern>[\u0000-\u001f\u0080-\uffff]</pattern>
            <text>${installdir}</text>
        </regExMatch>
    </ruleList>
</throwError>

The above will catch any character that may be illegal, including Unicode characters. This may cause issues for some OSes where paths may include non-latin characters, though.

Another option is to create a regular expression that checks that the path matches a specific pattern or only uses acceptable characters. For example:

<throwError>
    <text>Invalid value</text>
    <ruleList>
        <regExMatch>
            <logic>does_not_match</logic>
            <pattern>^[\u0020-\u003fA-Za-z:\\]+$</pattern>
            <text>${installdir}</text>
        </regExMatch>
    </ruleList>
</throwError>

This only accepts basic ascii characters, slash and back slash.

link

answered 22 Nov '12, 04:32

wojciechka's gravatar image

wojciechka ♦♦
7.8k61122
accept rate: 26%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×29
×3
×1

Asked: 21 Nov '12, 19:31

Seen: 1,301 times

Last updated: 22 Nov '12, 04:32