| 1 |
' |
| 2 |
' This file is part of the LibreOffice project. |
| 3 |
' |
| 4 |
' This Source Code Form is subject to the terms of the Mozilla Public |
| 5 |
' License, v. 2.0. If a copy of the MPL was not distributed with this |
| 6 |
' file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 7 |
' |
| 8 |
|
| 9 |
Option Explicit |
| 10 |
|
| 11 |
Function doUnitTest() As String |
| 12 |
On Error GoTo ErrorHandler ' Set up error handler |
| 13 |
|
| 14 |
Dim Xml As String |
| 15 |
Dim XmlLen As Long |
| 16 |
' Not namespace-well-formed XML, parse is expected to fail |
| 17 |
Xml = "<a:xml/>" |
| 18 |
XmlLen = Len(Xml) |
| 19 |
Dim XmlByte(1 To XmlLen) As Byte |
| 20 |
Dim Index As Integer |
| 21 |
For Index = 1 To XmlLen |
| 22 |
XmlByte(Index) = Asc(Mid(Xml, Index, 1)) |
| 23 |
Next |
| 24 |
Dim source As Object |
| 25 |
source = CreateUnoStruct("com.sun.star.xml.sax.InputSource") |
| 26 |
source.aInputStream = com.sun.star.io.SequenceInputStream.createStreamFromSequence(XmlByte) |
| 27 |
Dim parser As Object |
| 28 |
parser = CreateUnoService("com.sun.star.xml.sax.FastParser") |
| 29 |
' Parse crashed before the fix |
| 30 |
parser.ParseStream(source) |
| 31 |
|
| 32 |
' Shouldn't end up here |
| 33 |
doUnitTest = "FAIL" |
| 34 |
Exit Function |
| 35 |
ErrorHandler: |
| 36 |
doUnitTest = "OK" |
| 37 |
End Function |