Author: Jani

  • A PHP Regular Expression To Look For Unterminated img Tags

    After I had finally managed to craft this beast, I felt so proud that I just had to share it:

    /(<img([^\/]|\/(?!>))*)>/U

    If I were to try and translate this into common language, it would perhaps go like this: after each occurrence of <img, skip all non-/ characters, and also all occurrences of / immediately followed by a > — up until the next occurrence of >. Unless you have a match at that point — a > without an immediately preceding / — move on to the next occurrence of <img.

    And with each part of the expression in parenthesis, between quotation marks, following the corresponding translation: after each occurrence of <img, skip all (“*“) non-/ characters (“[^\/]“), and also (“|“) all occurrences of / immediately followed by a > (“\/(?!>)“) — up until the next occurrence of >. Unless you have a match at that point — a > without an immediately preceding / — move on to the next occurrence of <img.

    The outermost parentheses (/(<img...)>/U) grab the contents of the unterminated <img> tag apart from the closing angle bracket, so that it’s easy to pair with a “ />” to properly terminate it. Other parentheses are for defining subpatterns.

  • Old news, but news to me: WordPress security key definitions in wp-config.php

    While investigating an entirely separate issue with one of my WordPress installations, I came across this:

    “Beginning with WordPress Version 2.6, three (3) security keys, AUTH_KEY, SECURE_AUTH_KEY, and LOGGED_IN_KEY, are used to insure better encryption of information stored in the user’s cookies. Beginning with Version 2.7 a fourth key, NONCE_KEY, was added to this group.

    If you don’t find the keys in your wp-config.php file, add the keys definitions with reference to Editing wp-config.php – Security Keys, and upload to your server.”

    Step 13: Add security key definitions to the wp-config.php file
    WP Codex

    Since most of my WordPress installations are pretty ancient, and upgrading them has long since become a routine job, this was the first time I heard about this feature. So my blogs have been lacking in this security feature, until now (I set up the aforementioned keys in each of my wp-config.php files).

  • Abduction

    There was something vaguely familiar about the glowing blue backdrop of Windows 7 Beta’s installer. Then I remembered: Fedora 9.

  • Trying Python

    I tried my hands on the Snake, and was quickly defeated. It’s an ugly mess currently from the point of view of an international beginner: 2.5 (Lenny’s version) doesn’t work too well with unicode, and  3.0 isn’t yet in the repos. Ubuntu 8.10 has the basic 3.0 interpreter, but that failed me at the beginning of the 3rd chapter. Apparently the examples there require Tk, which for 3.0 isn’t in the repos.

    I was surprised by the somewhat flaky unicode support in 2.5. This was due to my misconception that Python was new — newer than Java for instance. As I have no background in Python, and no code to support either, I’m just happy they’ve fixed this in version 3.

  • WP:n SVN-päivittäminen ja räätälöity oletusteema

    Päivitin kaikki WordPress-blogit 2.7:ään. Siinä ilmeni, ettei SVN-päivittäminen pelaa kovin hyvin, jos teemana on kustomoitu default: SVN täyttää muokatut tiedostot muokkauksia ihmettelevistä kommenteista (<<<<<<< .mine) ja hakemiston .mine-päätteisistä varmuuskopioista (tjsp.).

    En keksinyt tähän äkkiseltään parempaakaan ratkaisua kuin kopioida (cp -a) kustomoidun teeman kokonaan uudelle nimelle, tuhota .mine-tiedostot ja nuo SVN:n lisäämät kommentit (sed -i '/blaablaa/d') kopiosta, sen jälkeen tuhota default-hakemiston kaikkineen (rm -rf) ja lopuksi noutaa uuden kopion alkuperäisestä defaultista SVN:llä (svn up).

  • My first ticket in the Debian BTS

    Just filed my first Debian bug — yay! And a boo to reportbug for not wrapping the lines and failing to mention it. Either would have resulted in a nicer layout on the web page: I could have wrapped the lines myself, had I known this. Oh well, I’ll know next time.

    Also, despite picking ‘novice’ mode in reportbug’s initial configuration, I was confused by the SMTP question “Do you have a “mail transport agent” (MTA) like Exim, Postfix or SSMTP configured on this computer to send mail to the Internet?” Since exim4 is installed by default, I picked the default (yes), and this resulted in my first report being lost, a fact which I could only verify by looking at exim’s log (which a true novice probably couldn’t do). There was no error message, and even worse, reportbug claimed to have sent the report successfully when it had in fact not done so.

    But anyway, I was fortunate to spot the broken link on debian.org, as that was a perfect excuse for finally trying this bugreporting thingy.

  • RIAs and Free Software

    Some issues with RIAs I’ve been wondering:

    • How come there’s no Flash-based Ogg player? Actually, it seems that a Vorbis player is being worked on, which is great, but I’m still puzzled that this hasn’t come about way, way earlier.
    • How come there’s no Flash-based Ogg player that would work with the free Flash player implementations? Granted that having one that works with the non-free plugin, which is the most prevalent, is of massively bigger importance for spreading Ogg, than having a fully freedom-friendly one. And also, those of us who choose to use the free implementations probably have no problems playing back Oggs without a Flash-based player. However, I’m not trying to be critical here; these are just issues that I find confusing in how the free software community works. (More on this below.)
    • Is Flash a non-free format? Is there such a thing as a ‘non-free format’, or am I just confused in my terminology?
    • Are there any truly free RIA platforms? I know of none. Based on what I understand from the Wikipedia article, Moonlight can hardly be considered one, given its MS-imposed restrictions.
    • If there aren’t any truly free RIA platforms, why not?

    As I said, this isn’t a criticism. I’m just genuinely puzzled by these questions and how the community works. More generally, I would presume that it would be natural for those striving to free people from non-free formats and software, to begin from their own side of things (the free software world), and from there to reach towards those still locked in. This would pave a nice, finished road for the unfree to flock back to the other side with them.

    Let’s say a locked-in user comes to contact with Ogg through a Flash-based player on the web. They then, through proper evangelising, start to contemplate switching to a free Flash player. But if the free player can’t play the Ogg files displayed on their favourite sites, they face the added difficulty of having to try and get them to play otherwise.

    If, instead, they’d find that the free Flash implementation they’ve now switched to plays the Ogg player just fine, they won’t have to go through the hoop of getting the Oggs to play otherwise — at least not until they start contemplating ditching Flash altogether for being a non-free format.

    And what about ditching Flash, if you still want to have RIAs in your truly free world? With Ogg itself it seems to me that the work began as it should have, with laying the foundations by creating a free alternative. But what if there’s no free alternative for the non-free RIA platforms?

  • Miro 1.2.8 is in the archive

    No need to compile Miro 1.2.8 for Lenny anymore, just pick it up from your local ftp mirror’s pool. It hasn’t yet migrated to testing and I don’t know if it will, but it (1.2.8-1) seems to work ok for me at least. And it fixes the issue with YouTube subscriptions, which was why I wanted to upgrade in the first place.

  • Uutinen: Ubuntu 8.10 (Intrepid Ibex) julkaistu

    Ubuntu 8.10, koodinimeltään Intrepid Ibex, on julkaistu, ja on nyt ladattavissa Ubuntu Suomen sivuilta. Tietoa uusista ominaisuuksista sekä muita lisätietoja tuoreesta jakeluversiosta löytyy esimerkiksi julkaisutiedotteesta ja julkaisumuistiosta.

    Itse olen käyttänyt virtuaalikoneessa Intrepid jo sen varhaisista testijulkaisuista (Alpha) lähtien Hardy Heronin rinnalla. Kehitysvaiheessa Intrepidin kohutuin uudistus oli sen uusi, tummiin sävyihin perustunut teema, johon ainakin minä alun kulttuurishokin jälkeen tykästyin kovasti. Tämä uudistus jätettiin lopullisesta julkaisusta pois, mutta sen saa halutessaan käyttöön valitsemalla Ulkoasu-asetussovelmassa DarkRoom-teeman.

    Ulkoasupuolella uudistukset typistyivät uuteen taustakuvaan, ja sekin on mielestäni vähemmän onnistunut kuin Hardyn tyylikäs haikara.

    Ulkoasunhan voi kuitenkin räätälöidä ihan mieleisekseen, joten tärkeintä on tietysti se, mitä on pinnan alla. Heti välittömimmän pinnan tuntumassa on Intrepidin mielestäni mielenkiintoisin uudistus, eli GNOME-työpöytäympäristön tuorein julkaisuversio 2.24. Sen jälkeen merkittävin uutuus on uunituore Linux-ydin, 2.6.27.

    Jatkossa tämän blogin merkinnät perustuvat Intrepid Ibexin käyttöön ainakin seuraavan version (jonka koodinimi on Jaunty Jackalope) julkaisuun saakka.

    Lopuksi muistuttaisin vielä, että niiden Hardy Heronin käyttäjien, jotka ovat tyytyväisiä nykyiseen järjestelmäänsä, ei ole syytä rynniä päivittämään sitä. Hardy Heronhan oli pitkällä aikavälillä tuettu julkaisu (LTS), eli sen käyttäjiä tuetaan vielä seuraavat kaksi ja puoli vuotta. Hardyn voi siis halutessaan päivittää vasta seuraavan LTS-julkaisun tapahduttua.

  • Temporary File Name

    For creating temporary files with unique names, there’s the hard way and then there’s the easy way.

    I would have left a comment about this on a little stupid blog, but the comments were closed, so I’m making this entry in the hopes that Google’ll pick it up and show it to someone like I was a minute ago, forgetting the name of mktemp.