escape xml restricted chars#3
Conversation
|
To elaborate: We have a Service in Icinga where a PowerShell script is used for verifying the service state. When the script runs into an error (read Exception) PowerShell tends to print these errors in red. This is done by using regular ANSI control characters. For example: The output from the Shell is taken by Icinga as is, including the ANSI characters. This is also the value sent to ilert via the API. Upon receiving the string the API rejects the request because the XML is seen as invalid. Looking at the W3C Recomendation (here) there is a range of characters the use of is "discouraged". This PR removes the whole range of unsupported characters. When applying the Regex from the PR using the example string above it results in this: Note the control characters have been removed. There is the slight caveat that only single characters are checked and removed. The full control sequence This could be caught as well if needed. To do so the regex needs to be extended. A first test with this regex works: (taken from here) Result: |
ilert returns a HTTP 400 if there are restricted XML characters anywhere in the request. This fix removes such characters from any payload entry.