MantisBT: How to switch off inserting [^] into notes - mantis

When I add a XML document into a Mantis note, e.g. an XML fragment:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
Mantis considers the XML namespace declaration as a hyperlink and adds a "[^]" string behind:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> [^]
If the user copy/pastes the XML from Mantis it is not valid due to these unwanted strings.
Is there any way how to switch this feature off?

You appear to be using a legacy version of Mantis; you can switch off URL processing by changing the corresponding setting in the MantisCoreFormatting plugin: go to Manage > Manage Plugins then click on MantisBT Formatting and set URL Processing to Off).
Note that recent versions of MantisBT no longer insert the [^].

Related

Delphi THttpClient: post's IHttpResponse giving encoded string seen in fiddler webview

I have a THTTPClient giving a strange response (apparently UTF-16 encoding?) when invoking lHttpResp.ContentAsString().
The string comes through as this:
㰀㼀砀洀氀 瘀攀爀猀椀漀渀㴀∀㄀⸀ ∀ 攀渀挀漀搀椀渀最㴀∀唀吀䘀ⴀ㄀㘀∀ 猀琀愀渀搀愀氀漀渀攀㴀∀礀攀猀∀㼀㸀਀㰀刀䔀匀唀䰀吀㸀਀    㰀倀䄀夀倀䄀䜀䔀唀刀䰀㸀栀琀琀瀀猀㨀⼀⼀攀攀⸀琀攀猀琀⸀瀀愀礀最愀琀攀眀愀礀⸀挀漀洀⼀䠀漀猀琀倀愀礀匀攀爀瘀椀挀攀⼀瘀㄀⼀栀漀猀琀瀀愀礀⼀瀀愀礀瀀愀最攀⼀㄀㘀㜀 㔀㘀㘀㈀㄀㔀㐀㌀㈀㐀欀䬀䬀儀㔀唀漀䈀椀吀氀㠀䔀爀䈀䴀 戀㰀⼀倀䄀夀倀䄀䜀䔀唀刀䰀㸀਀    㰀匀䔀匀匀䤀伀一吀伀䬀䔀一㸀㄀㘀㜀 㔀㘀㘀㈀㄀㔀㐀㌀㈀㐀欀䬀䬀儀㔀唀漀䈀椀吀氀㠀䔀爀䈀䴀 戀㰀⼀匀䔀匀匀䤀伀一吀伀䬀䔀一㸀਀㰀⼀刀䔀匀唀䰀吀㸀਀
Running Fiddler, I can see the response is fine when looking at the raw or text view, but matches the above encoding when looking at Webview. I'm probably missing something pretty obvious here, but I've tried converting with TEncoding to no avail, as per this thread:
Delphi - converting string back from UTF-8
Fiddler's text view gives a correct text:
<?xml version="1.0" encoding="UTF-16" standalone="yes"?>
<RESULT>
<PAYPAGEURL>https://url/</PAYPAGEURL>
<SESSIONTOKEN>1670565241202KKv4NPBBScANOL6rxbi</SESSIONTOKEN>
</RESULT>
A colleague helped with this and found it was TEncoding.BigEndianUnicode, it was one of the only ones I hadn't tried due to tunnel vision. Resolution seen below. Thanks for your input.
lHttpResp.ContentAsString(TEncoding.BigEndianUnicode); //to get the result in text for testing etc
XmlFile.LoadFromStream(lhttpResp.ContentStream); //to load to an xmlfile

SAXParseException when using restassured

I am trying to verify a XML response with rest-assured like this:
.then().body("some.xml.path", is("abc"));
However, what I get is a SAXParseException:
DOCTYPE is disallowed when the feature "http://apache.org/xml/features/disallow-doctype-decl" set to true.]
Response starts like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE cXML SYSTEM "http://xml.cXML.org/schemas/cXML/1.2.021/cXML.dtd">
<cXML ...
Why am I getting this exception? What should I change?
I am using version 3.2.0 of rest-assured.
A similar question has been answered here. In short, the answer describes to use disableLoadingOfExternalDtd() to have RestAssured ignore the Document Type Definition in your XML.
Normally, the DTD would describe (using the external definition) the structural layout of the element defined as cXML.

Validating XML with an in-memory DTD in C using libxml2

I need to validate XML using DTD stored in memory, i.e. something like the following:
static const char *dtd_str = "<!ELEMENT ...>";
xmlDtdPtr dtd;
dtd = xmlParseMemoryDtd(dtd_str);
XML_PARSE_DTDVALID parser option allows to validate DTD embedded into XML:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE some_tag[
<!ELEMENT some_tag ...>
...
]>
<some_tag>...</some_tag>
So a workaround is to modify in-memory XML. Things become more complicated with
a parser used in "push mode". In push mode we have to detect whether the XML
declaration (<?xml ...?>), or start of the root element, then put our inline
DTD between them.
Could you suggest better solution?
EDIT
A workaround is to validate parsed XML posteriori as Daniel(_DV) suggested below.
Example: main.c, response.xml.
But I was searching for way to "embed" a DTD and validate XML "on-the-fly" while libxml2 parses XML chunk-by-chunk.
The following aproach doesn't work for me:
xmlCtxtUseOptions(ctxt, XML_PARSE_NOENT | XML_PARSE_NOWARNING | XML_PARSE_DTDVALID);
ctxt->sax->internalSubset = ngx_http_file_chunks_sax_internal_subset;
ctxt->sax->externalSubset = NULL;
$ ./parsexml
validity error : Validation failed: no DTD found !
<response>
^
Document is not valid
xmlValidateDtd allows to do DTD validation a posteriori of an already parsed XML document
to make sure it validates against the DTD. This will not use the internal subset...
http://xmlsoft.org/html/libxml-valid.html#xmlValidateDtd
See xmllint.c code in libxml2 for a full example of how to use it,
Daniel

Mule ESB IMAP questions

Currently we need fetch mails from an IMAP server using Mule ESB. Once the mails have been fetched, we only need the attachments and save them on the harddrive. So far so good. Now I got a couple of questions:
How do I keep the original name intact using a file:outbound-endpoint?
How can I check how many attachments I got?
How do save a copy of the mail on the IMAP and local drive?
#1: I tried #header:fileName or #originalFileName or even removing the outputpattern (this results in the filename being "35c7dea0-519a-11e1-b8b2-092b658ae008.dat")
#2: I am trying to make a flow where I check how many attachments there are. If there are less then 1 then I want to save the files and no further process them. If it's more then 1, then save it and process it. I tried COUNT but it didn't work.
#3: am trying to MOVE a message when READ to a back-up folder on the IMAP-server. On top of that I'll save a copy on the local server. Problem is that with the current code, the message does not get marked as read nor moved. The messages stay unread and they get copied (over and over, enldess loop) instead of getting moved to the IMAP back-up folder. When enabling the deleteReadMessages then the loop is broken but the message does not get copied on the IMAP.
Here's the code I am currently using:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:imap="http://www.mulesoft.org/schema/mule/imap"
xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:email="http://www.mulesoft.org/schema/mule/email"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/3.2/mule-file.xsd
http://www.mulesoft.org/schema/mule/imap http://www.mulesoft.org/schema/mule/imap/3.2/mule-imap.xsd
http://www.mulesoft.org/schema/mule/email http://www.mulesoft.org/schema/mule/email/3.2/mule-email.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/3.2/mule-vm.xsd">
<imap:connector name="imapConnector" checkFrequency="5000"
backupEnabled="true" backupFolder="/home/mark/workspace/Eclipse/RHZ_Project/src/Archive/"
mailboxFolder="INBOX" moveToFolder="INBOX.Backup" deleteReadMessages="false"
defaultProcessMessageAction="SEEN" />
<expression-transformer name="returnAttachments">
<return-argument evaluator="attachments-list" expression="*.txt,*.ozb,*.xml" optional="false"/>
</expression-transformer>
<flow name="Flow1_IMAP_fetch">
<imap:inbound-endpoint user="USER" password="PASS" host="IP"
port="143" transformer-refs="returnAttachments" disableTransportTransformer="true"/>
<collection-splitter/>
<file:outbound-endpoint path="/home/mark/workspace/Eclipse/RHZ_Project/src/Inbox/#[function:datestamp].dat">
<expression-transformer>
<return-argument expression="payload.inputStream" evaluator="groovy" />
</expression-transformer>
</file:outbound-endpoint>
</flow>
</mule>
1) How do I keep the original name intact using a file:outbound-endpoint?
Attachments are javax.activation.DataHandler instances so you should be able to call getName() on them, with an OGNL or Groovy expression. For example:
#[groovy:payload.name]
Should give you the original attachment name.
2) How can I check how many attachments I got?
Before the splitter, use a choice router and an condition that checks the size() attribute of the attachment list, like:
#[groovy:payload.size()>1]
3) How do save a copy of the mail on the IMAP and local drive?
I do not know what the issue is here. Maybe marking as seen is not supported. Or maybe the fact that you disable the transport transformer prevents a post-read action to kick in.
By the way, I suggest you leave the default transport transformer as-is and move the returnAttachments transformer after the inbound endpoint, before the splitter.

PartCover browser not opening code files

We're generating PartCover reports via the command line tool along with our CruiseControl.Net unit tests. This generates an xml file that displays the results nicely on the cruisecontrol dashboard. The xslt transforms that are included only show you the percentage of coverage in an individual class. We want to know exactly what lines are not being covered. The problem ist when we open the report in the PartCover browser and double click a method it doesn't show us our cs files. I know the PartCover browser is capable of showing you the files because of the following.
Here's a screenshot of PartCover browser with the lines of code showing: http://kjkpub.s3.amazonaws.com/blog/img/partcover-browse.png.
The information looks like it should be available to the browser because the report contains this:
<Method name="get_DeviceType" sig="Cathexis.IDBlue.DeviceType ()" bodysize="19" flags="0" iflags="0">
<pt visit="2" pos="0" len="1" fid="82" sl="35" sc="13" el="35" ec="14" />
<pt visit="2" pos="1" len="4" fid="82" sl="36" sc="17" el="36" ec="39" />
<pt visit="2" pos="5" len="2" fid="82" sl="37" sc="13" el="37" ec="14" />
</Method>
and this:
<File id="66" url="D:\sandbox\idblue\idblue\trunk\software\code\driver\dotnet\Common\AsyncEventQueue.cs" />
All I want to be able to do is view what lines of code are not being covered in my test cases without having to figure out what the xml above is trying to tell me.
Thanks to anyone in advance who replies.
I figured out why the cs files were not displaying. The paths were incorrect in the xml file because our test project was being built on a different machine than the one partcover was on. (partcover must generate the .cs file paths from pdb files maybe?) Once I search and replaced the file switching the base directory of our subversion location to the one on the other machine all was well.

Resources