Jump to content

Script filter stumbles on special characters in xml.


Recommended Posts

Hi Alfred users.

 

I'm not completely sure this is a bug so I'm posting it here first. 

 

I have written a script that outputs xml which some times contains special characters.

It seems that the xml interpreter in Alfred does not know what to do with those and aborts the whole script filter without any error in the debug log. A simple example would be:

 

<?xml version="1.0" encoding="UTF-8"?><items><item arg="http://www.glossed.it/highlights" valid="YES" type="file"><title>title Ð</title><subtitle>test</subtitle><icon type="fileicon"></icon></item></items>

 

I've coloured the offending character red. Without it the script filter works fine.

 

Am I correct in thinking this is a bug in Alfred?

 

Best regards,

Teo

Link to comment

It will also work without using XML entities, but you have to actually encode the text to UTF-8 (which is what you've declared as the charset in the XML header).

 

Nevertheless, as Tyler says, you're better off using a library to generate your XML for you. It's not entirely straightforward.

Edited by deanishe
Link to comment

Thank you everyone for your suggestions.

 

Not knowing much about the xml I just ran the output through a few online xml verifier tools which all came back OK.

 

I will have a deeper look now that I know the fault is on my side of things.

 

:)

Teo

Link to comment

Chances are your browser is correcting the encoding when you paste the text into the form field (browsers are very good at that).

The best thing to do it what Tyler advised and use an XML generation library (or one of the workflow helper libraries) to produce your XML.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...