Dave Heavy Industries » Development http://www.daveheavyindustries.com Dave Heavy Industries - blog Mon, 12 Aug 2013 00:24:10 +0000 en-US hourly 1 http://wordpress.org/?v=3.6 ASP Classic – Escape string for JS http://www.daveheavyindustries.com/2011/10/25/asp-classic-escape-string-for-js/ http://www.daveheavyindustries.com/2011/10/25/asp-classic-escape-string-for-js/#comments Tue, 25 Oct 2011 05:58:08 +0000 admin http://wp.daveheavyindustries.com/?p=247 for those that know me... ASP Classic is a pain I have to deal with every day... the simplest things that you've come to accept from every other language is just painful in ASP Classic. Every time I have to do something that I shouldn't have to do, I try to help as many people as possible not have to work it out for themselves. Here is a function to escape a string for use in JS. Enjoy.

Function js_escape(ByRef input_string)

    If NOT IsNull(input_string) AND input_string <> "" Then
        Dim working_string
        working_string = input_string
        working_string = Replace(working_string, vbNewLine, "\n")
        working_string = Replace(working_string, vbTab, "\t")
        working_string = Replace(working_string, "'", "\'")
        ' .. other escape values/strings you may wish to add
        js_escape = working_string
    End If
End Function
]]>
http://www.daveheavyindustries.com/2011/10/25/asp-classic-escape-string-for-js/feed/ 0
GoDaddy hosted wordpress facebook featured images http://www.daveheavyindustries.com/2011/08/29/godaddy-hosted-wordpress-facebook-featured-images/ http://www.daveheavyindustries.com/2011/08/29/godaddy-hosted-wordpress-facebook-featured-images/#comments Mon, 29 Aug 2011 00:49:06 +0000 admin http://wp.daveheavyindustries.com/?p=171 I had the strangest issue last week, featured images from wordpress would not appear on a facebook post... sometimes.

The story began a few weeks ago while I was in koh-samui. My host of choice had a SAN failure and ended up having 4 days of downtime. Unacceptable under any circumstances, so I've started looking at other hosts. I setup a test site on godaddy for one of my clients, but as GoDaddy was also the DNS server, they moved the site as soon as it was setup leaving me with a choice of fixing the DNS back to the existing host, or moving the site in a hurry to godaddy. As my customer wasn't paying for hosting I decided to most the hosting to GoDaddy. Bad move.

The reliability on GoDaddy was perfect, the speed even wasn't bad (not as fast as my locally hosted box, as you'd expect, but not bad).  The issue came because my client was complaining that every facebook share, sometimes the descriptions wouldn't appear in the shared post, and almost always the image was missing.

I went through everything a few times and discovered that if I shrank the featured thumbnail presented to facebook to 100x100, the chance of it appearing increased to about 50%, but was still unacceptable. The links were fine, and my browser was able to see the image_src and pick the image up.

I finally gave up and moved the site back to the old host and immediately it started working correctly. Strange. Lesson learnt - cheap hosting just isn't worth it.

 

]]>
http://www.daveheavyindustries.com/2011/08/29/godaddy-hosted-wordpress-facebook-featured-images/feed/ 0
Unable to post link to facebook http://www.daveheavyindustries.com/2011/04/29/unable-to-post-link-to-facebook/ http://www.daveheavyindustries.com/2011/04/29/unable-to-post-link-to-facebook/#comments Fri, 29 Apr 2011 05:29:27 +0000 admin http://wp.daveheavyindustries.com/?p=153 Strange one this morning. Our e-comm guys reported they were unable to post any links to their page, their own wall, other peoples walls... anywhere on facebook really. only "The message could not be posted to this Wall." was presented to them as an error.. useful??!?? I think not. After a bit of investigation, I found that it was some pages but not others. The home page for example worked, but a product would not. A content page would, but a category page would not. Ugh.

They all use the same template so I thought surely the html would be very similar... and it was. I ran the pages through the w3c validator, and made a bunch of unecessary changes to do with short-tags and pulled my hair out some more.

A few more coffees and some tweeting and googling brought to my attention that the error "The message could not be posted to this Wall." could be due to facebook blocking that url due to abuse... maybe one of our competitors complained to upset our social strategy? no - then all of the urls would be broken (only lost an hour here :| )

I went back to the HTML, removed anything fancy and it still didn't work. I decided not to let this get the better of me, and I went through the html line by line looking for anything out of the ordinary... and there it was.

Canonical link was missing a slash. <link rel="canonical" href="https:/somedomain.com" />. Now this was set by our e-commerce system, not by the template or development, and none of that has changed for a really long time, meaning that something at facebooks end has tightened up the validation. Anyway, not pointing fingers, commented it out and Posts are now sharing as expected. ugh.

 

 

]]>
http://www.daveheavyindustries.com/2011/04/29/unable-to-post-link-to-facebook/feed/ 0
Decoding Windows Script Encoder encoded scripts http://www.daveheavyindustries.com/2011/04/28/decoding-windows-script-encoder-encoded-scripts/ http://www.daveheavyindustries.com/2011/04/28/decoding-windows-script-encoder-encoded-scripts/#comments Thu, 28 Apr 2011 05:34:08 +0000 admin http://wp.daveheavyindustries.com/?p=145 Decoding Windows Script Encoder encoded scripts

isn't that a mouthful? Microsoft released this in 2001 - http://www.microsoft.com/downloads/en/details.aspx?FamilyID=e7877f67-c447-4873-b1b0-21f0626a6329 which is a way of obscurifying vbscript (like ASP) scripts so that people can't change or copy your code. Great, right? well, as with most script encoding  (zend encoder aside, others I'm sure), it doesn't do a very good job of it, and more makes it annoying to debug asp pages when the developers encode their includes.

I ran into this particular problem when dealing with ProductCart by EarlyImpact. I ran into some issues integrating with their XMLtools, opened it up and to my surprise was presented with gibberish like below..

<snip><%#@~^K6gAAA==@#@&@#@&UE(PZ4+1V?Mm6D9+.d:lokc#@#@&fbh~Z4k^NHW[nk~dYMHW9+SOsw1G[1C:SD:2gW9+.mV!n~D:2.mV;n</snip>

small amount of reading later, discovered Microsoft script encoder, decided that this can't be the end of it, and googled microsoft script decoder, hit the I'm feeling lucky button and blamo! success :D

http://www.greymagic.com/security/tools/decoder/

there's also a downloadble program to do the same thing if you have a lot of scripts to decode - http://www.virtualconspiracy.com/index.php?page=scrdec/intro

within minutes I'd discovered where I was going wrong with my REST request xml and was back to being productive. happy days.

hope I've saved someone some headaches.

disclaimer - proof of concept as to why you shouldn't trust your IP to the microsoft script encoder, not a way to rip off your competitors, extend your trials or anything of the similar.

 

]]>
http://www.daveheavyindustries.com/2011/04/28/decoding-windows-script-encoder-encoded-scripts/feed/ 0