Re: [Hampshire] obfuscated code

Top Page
Author: Andy Smith
Date:  
To: Hampshire LUG Discussion List
Subject: Re: [Hampshire] obfuscated code

Reply to this message
gpg: failed to create temporary file '/var/lib/lurker/.#lk0x572b5100.hantslug.org.uk.27969': Permission denied
gpg: keyblock resource '/var/lib/lurker/pubring.gpg': Permission denied
gpg: Signature made Mon Mar 14 14:21:53 2011 GMT
gpg: using DSA key 2099B64CBF15490B
gpg: Can't check signature: No public key
Hello,

On Sun, Mar 13, 2011 at 05:16:42PM +0000, john lewis wrote:
> <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#66;&#97;&#114;&#98;&#97;&#114;&#97;&#77;&#97;&#108;&#108;&#121;&#111;&#110;&#64;&#108;&#101;&#119;&#109;&#97;&#108;&#46;&#99;&#111;&#46;&#117;&#107;">&#66;&#97;&#114;&#98;&#97;&#114;&#97;&#32;&#77;&#97;&#108;&#108;&#121;&#111;&#110;</a>
>
> I don't know what software was used to set it up, probably some windows
> based gui website design tool.
>
> Does anyone have a clue as to how I can decode the page so I can edit?
> it. The original webmaster is unavailable for the moment so cannot ask
> what software he used.


John asked me off-list how to add a new entry. It wasn't immediately
obvious to me that he'd asked this originally, but now I read again
I suppose "so I can edit" implies needing to go the other way too.

I'd do something like piping what I wanted to encode through:

perl -MHTML::Entities -ne 'print HTML::Entities::encode_entities_numeric($_, "\x0-\xfff"), "\n"'

e.g.:

$ echo -n 'mailto:andy@bitfolk.com' | perl -MHTML::Entities -ne 'print HTML::Entities::encode_entities_numeric($_, "\x0-\xfff"), "\n"'

&#x6D;&#x61;&#x69;&#x6C;&#x74;&#x6F;&#x3A;&#x61;&#x6E;&#x64;&#x79;&#x40;&#x62;&#x69;&#x74;&#x66;&#x6F;&#x6C;&#x6B;&#x2E;&#x63;&#x6F;&#x6D;

$ echo -n 'Andy Smith' | perl -MHTML::Entities -ne 'print HTML::Entities::encode_entities_numeric($_, "\x0-\xfff"), "\n"'

&#x41;&#x6E;&#x64;&#x79;&#x20;&#x53;&#x6D;&#x69;&#x74;&#x68;

If you're using vi/vim as an editor you can replace text with the
output of a command, so if you had a line like so:

mailto:andy@bitfolk.com

Then going to the start of the line and typing:

!$perl -MHTML::Entities -ne 'print HTML::Entities::encode_entities_numeric($_, "\x0-\xfff")'

would replace the line with

&#x6D;&#x61;&#x69;&#x6C;&#x74;&#x6F;&#x3A;&#x61;&#x6E;&#x64;&#x79;&#x40;&#x62;&#x69;&#x74;&#x66;&#x6F;&#x6C;&#x6B;&#x2E;&#x63;&#x6F;&#x6D;&#xA;

(note you get an unwanted "&#xA;" on the end because it converted
the newline as well)

Perhaps that would be useful in not disturbing your editing flow.

If you don't do this sort of thing a lot then you could just search
the web for any of what must be thousands of online "convert to
numeric html entities" web forms, e.g.:

http://www.texaswebdevelopers.com/examples/xmlentities/xml_entities.asp

Cheers,
Andy

--
<Ging> i stopped taking my medication long ago. the ironey is it was for
social anxioty disorder and now i daren't go back to the doctor to get
another perscription