Feed aggregator

Escaping in iCalendar and vCard

Planet-PHP - Fri, 10/05/2013 - 17:57

The #1 bug report in my vObject library (a library to parse and create iCalendar and vCard objects in PHP) is that it does a bad job escaping/un-escaping of values.

In particular, it double-escapes certain values, changing things like ; into \\; and in other cases it's a bit too liberal un-escaping.

It's gotten to a point where I got so frustrated about this bug, I've been working all week on a new version of the parser.

Determined to do things right this time, I wanted to make sure I complied with all the relevant standards, in particular:

When I first wrote the vObject I naively thought that these formats were more or less the same. On the surface it does indeed seem that way, everything does seem to follow this basic structure:

BEGIN:VCARD
VERSION:4.0
FN:Evert Pot
END:VCARD

The nuances and slight difference between the specifications are enough to drive a simple person to madness though.

Just on the topic of ecaping values (the part after the :) the specifications have the following to say:

vCard 2.1

vCard 2.1, as well as the other specs have a concept of 'compound' or multi-value properties. An example:

BEGIN:VCARD
VERSION:2.1
N:Pot;Evert;Middle;Dr.;M.D.
END:VCARD

As you can see, the N property has multiple values. Any of these values may also contain a ;, which must be escaped as \;. So we also cannot blindly encode a string and automatically add backslashes to any ; we see.

The semi-colons should only be escaped in the ADR, ORG and N fields, but we can assume that backslashed semi-colons may also appear in other values.

Any property may have a parameter, a parameter looks a bit like this:

BEGIN:VCARD
VERSION:2.1
NOTE;ENCODING=QUOTED-PRINTABLE:Handsome guy, for sure..
END:VCARD

A parameter in vCard starts with a ;, has a name and a value. Only the colon may be escaped in parameters, using \:.

If you somehow wanted to encode a real backslash though, there's no mention of escaping it as a double-backslash.

If you need newlines in any values, quoted-printable encoding must be used. Other specs all encode newlines as \n or \N.

vCard 3.0

rfc2425 says that backslashes (\\), newlines (\N or \n) and comma's (\,) must always be escaped, no exceptions.. Well except when the comma is used as a delimiter for multiple values.

rfc2426 add semi-colon (\;) to this list, except when it's used as a delimiter. Semi-colon is used as a delimiter in the N, ADR, GEO and ORG fields. NICKNAME and CATEGORIES use comma's.

vCard also says that individual parts of ADR, and N may also contain multiple values themselves, which are themselves split by a comma.

Quoted-printable is now deprecated, and should no longer be used.

Parameters have also changed. The new rule is that parameters must not contain ;, : or ", unless they are surrounded by double-quotes, in which case only " may not appear. Escaping of the colon character (\:) has disappeared.

vCard 4.0

vCard 4 changes the interpretation of 3.0 a bit, and now states that semi-colons may be escaped, depending on the property.

The implication is that we need to maintain lists of properties, if they support multiple- or compound-values and which delimiter they use (, or ;).

Semi-colons are now used by N, ADR, ORG and CLIENTPIDMAP. Comma's are used by NICKNAME, RELATED, CATEGORIES and PID.

Even though the spec does say that comma's must always be escaped, it does appear to violate this rule in it's own examples, specifically the example for GEO (which is no longer a compound float value, but a url).

iCalendar 2.0

iCalendar 2

Truncated by Planet PHP, read more at the original (another 1860 bytes)

Categories: Open Source, PHP Community

NetTuts.com: 10 Tips for Learning a New Technology

PHPDeveloper.org - Fri, 10/05/2013 - 17:54

On NetTuts.com today they've posted a list of tips they think will help you learn a new technology faster. They've broken it up into ten different steps, some which could be done at any time but some have a bit more of an order.

We live in a very exciting time. Never before has education been so cheaply available to the masses (if not free). The medium, itself, has made tectonic shifts from a classroom setting, to blogs, screencasts and complete university classes, as a set of videos and interactive forums. Given these resources, there's absolutely no excuse not to dive in and learn. However, with such a wealth of resources, filtering through the options can often become overwhelming. In this article, I will outline a simple process to kick-start your education.

Among the items in their list there's things like:

  • "Let the Information Flow Begin"
  • "Listen and Watch"
  • "Blogging"
  • "Feel the Pulse"
  • "Meetups and Conferences"

Each tip comes with a bit of description and some links to other resources and tools that can help you along your way.

Link: http://net.tutsplus.com/articles/general/10-tips-for-learning-a-new-technology

PHP.net: PHP 5.4.15 and PHP 5.3.25 released!

PHPDeveloper.org - Fri, 10/05/2013 - 16:49

On the PHP.net site they've announced the release of version 5.4.15 & 5.3.25 (fully released after some propagation issues with the mirror servers).

The PHP development team announces the immediate availability of PHP 5.4.15 and PHP 5.3.25. These releases fix about 10 bugs aswell as upgrading the bundled libmagic library. All users of PHP are encouraged to upgrade to PHP 5.4.15. [...] The list of changes are recorded in the ChangeLog.

Changes include updates to debug_backtrace for a segfault issue, a change to the dns_get_record function for negative length values and a fix for a fd leak on Solaris. You can download this latest release from the downloads section (source) or the Windows QA site (binaries).

Link: http://php.net/archive/2013.php#id2013-05-09-1

Community News: Packagist Latest Releases for 05.10.2013

PHPDeveloper.org - Fri, 10/05/2013 - 15:06
Recent releases from the Packagist:

Making better object oriented design decisions

Planet-PHP - Fri, 10/05/2013 - 13:00
Last week I finished up the first section of The Object Oriented PHP Masterclass. The class was great, and I learned about as much from my students as they learned from me. One of the most common questions I got from my students was “how do I make decisions about how to design my object [...]
Categories: Open Source, PHP Community

Aura: New Site, New Logo, New Releases

Planet-PHP - Fri, 10/05/2013 - 03:10
Last week we updated the project site layout with a variation on Bootstrap called Spacelab, and incorporated our new logo. Along with that, over the past few weeks, we have been quietly releasing updated versions of all our library packages. … Continue reading
Categories: Open Source, PHP Community

Web & PHP Magazine: May 2013 Issue - "Time Travel"

PHPDeveloper.org - Thu, 09/05/2013 - 20:23

The Web & PHP Magazine has officially released their latest issue - the May 2013 edition, "Time Travel".

You may already be familiar with Git, but did you know that it can rewrite time itself? GitHubber Ben Straub explains all in this month's issue, which also features tutorials on extracting XML data from RSS, using Composer to manage project dependencies and using the PHP Content Repository. If you've ever thought about starting a PHP user group, Atlanta PHP User Group co-organiser Kevin Roberts shares his secrets - plus, there's our regular columns on agile, big data and testing.

Articles included in this latest issue include:

  • "Change the Past" (Ben Straub)
  • "Why do User Groups?" (Kevin Roberts)
  • "Sprint Retrospective Primer" (Steffan Surdek)
  • "Urban Legends and Error Handling" (Stefan Priebsch)
  • "Managing your project's dependencies with Composer" (Jefersson Nathan de O. Chaves)

As always, this issue is available free of charge and can be downloaded directly from their site.

Link: http://webandphp.com/May2013

PHPMaster.com: Maven and PHP

PHPDeveloper.org - Thu, 09/05/2013 - 19:42

PHPMaster.com has a new tutorial posted that introduces you to a build tool that's more common in the Java world but can easily support PHP projects, Apache's Maven.

Apache Maven is a build automation tool with the purpose of building, reporting, and creating documentation of projects. It builds projects using a Project Object Model (POM) and a set of plugins shared by all projects using Maven, thus providing a uniform build system. Once you familiarize yourself with how one Maven project builds, you automatically know how all Maven projects build. [...] Through this article you will gain familiarity with Maven for PHP, and how to install and use the PHP-Maven plugin from the command line and in Eclipse.

The tutorial walks you first through the basic install of Maven and get you started with an example "settings.xml" file helping to set up the PHP-Maven plugin. They help you create your first project using the Archetype plugin and its related "pom.xml" file. The project already has a defined structure (similar to what you might see in a Composer-loadable PHP repo on Github) for the source of your app and the tests. They show you how to hook in PHPUnit and phpDocumentor for testing/dcumentation builds and, finally, how to integrate it all into Eclipse to allow for easier, in-IDE interactions.

Link: http://phpmaster.com/maven-and-php

Script-Tutorials.com: Functional Programming - How to Write Functional Code in PHP

PHPDeveloper.org - Thu, 09/05/2013 - 18:04

On the Script-Tutorial.com site today there's a new post looking at functional programming in PHP - some of the concepts involved and example code showing how to make it work.

Functional programming can be defined in simple terms as a programming paradigm that do not change the state of a program instead it uses pure functions. A pure function is a function that has the ability to accept a value and return another value without changing the input supplied to it. It is characterized by its ability to support functions that are of high order. [...] A programming paradigm that is functional has the following attributes: do not alter the states which make parallelism easier, deals mostly with a function which is the smallest unit hence enhances readability of code, has deterministic functions that enable stability of a program.

He talks some about anonymous/lambda functions (closures) and their role in PHP's implementation of functional programming. He also talks some about partial functions, currying, higher order functions and recursion. He finishes off the article with a look at some of the advantages this method of development can bring as well as some of the disadvantages that come with things like recursion and the learning curve of the method.

Link: http://www.script-tutorials.com/functional-programming-php

PHP.net: PHP 5.5.0RC1 is available

PHPDeveloper.org - Thu, 09/05/2013 - 17:27

As is mentioned on PHP.net today, the first release candidate for the PHP 5.5.x series, PHP 5.5.0RC1, has been released for testing:

The PHP development team announces the availability of the first release candidate of PHP 5.5. This release fixes some bugs as well as some possible leaks from our last beta. This is a development preview - do not use it in production!

Some of the more major changes in this release include an update to the FPM SAPI for QUERY_STRING, a fix for a build issue with libgd, bugs in SNMP and a problem with stream_select on Windows x64 systems. You can find the full list of changes in the NEWS file. Please download and test (Windows binaries here) this latest release to help the development team find issues and move along with the PHP 5.5.x releases.

Link: http://php.net/index.php#id2013-05-09-2

PHPClasses.org: Lately in PHP, Episode 35 - Better Documentation for PHP internals

PHPDeveloper.org - Thu, 09/05/2013 - 16:12

On PHPClasses.org today they've posted the latest episode of their "Lately in PHP" podcast series - Episode #35, "Better Documentation for PHP internals".

With the inclusion of Zend Optimizer+ extension in PHP 5.5, the need for better documentation of PHP internals became more evident, so PHP contributors can write extensions that take the most of the core PHP features. That is one of the topics discussed by Manuel Lemos and Ernani Joppert in the episode 35 of the Lately In PHP podcast. They also talked about having more optimized PHP opcodes, some interesting PHP feature proposals that got rejected, as well the article about the top version control systems used by PHP developers.

You can listen to this episode in a few different ways - either through the in-page player, by downloading the mp3 or by watching the video of the recorded Google Hangout session.

Link: http://www.phpclasses.org/blog/post/207-Better-Documentation-for-PHP-internals--Lately-in-PHP-podcast-episode-35.html

Community News: Packagist Latest Releases for 05.09.2013

PHPDeveloper.org - Thu, 09/05/2013 - 15:06
Recent releases from the Packagist:

Better Documentation for PHP internals - Lately in PHP podcast episode 35

Planet-PHP - Thu, 09/05/2013 - 11:32
By Manuel Lemos
With the inclusion of Zend Optimizer+ extension in PHP 5.5, the need for better documentation of PHP internals became more evident, so PHP contributors can write extensions that take the most of the core PHP features.

That is one of the topics discussed by Manuel Lemos and Ernani Joppert in the episode 35 of the Lately In PHP podcast.

They also talked about having more optimized PHP opcodes, some interesting PHP feature proposals that got rejected, as well the article about the top version control systems used by PHP developers.

Listen to this podcast, or watch the hangout video, or read the transcript to learn more about this and other interesting PHP discussions.
Categories: Open Source, PHP Community

Seriously: PHP 5.4.15 and PHP 5.3.25 really were released!

Planet-PHP - Thu, 09/05/2013 - 00:00
We weren't trying to pull an April Fool's Day joke in May. A temporary glitch caused the latest distributions of PHP to not properly propagate to the mirror servers. This has been fixed at the root level, and it's now being distributed to all of the mirrors. We'll take some bacon to go with the egg on our faces, please!If you continue to experience issues with downloading these versions after 21:00 UTC on 9 May, 2013, please drop us a line at php-mirrors@lists.php.net, telling us from which mirror you're trying to download, and we'll get it resolved.We apologize for the delays and confusion this may have caused, and thank you for using PHP.
Categories: Open Source, PHP Community

PHP 5.5.0RC1 is available

Planet-PHP - Thu, 09/05/2013 - 00:00
The PHP development team announces the availability of the first release candidate of PHP 5.5. This release fixes some bugs as well as some possible leaks from our last beta. THIS IS A DEVELOPMENT PREVIEW - DO NOT USE IT IN PRODUCTION! You can find an incomplete changelog of PHP 5.5.0RC1 here : Ignore QUERY_STRING when sent in SCRIPT_FILENAME in FPM SAPI.Fix build with system libgd >= 2.1 which is now the minimal version required (as build with previous version is broken). No change when bundled libgd is used. Fixed some bugs in SNMP Fixed bug where stream_select() fails with pipes returned by proc_open() on Windows x64). To get the full changelog, please, check the NEWS file attached to the archive. For source downloads of PHP 5.5.0RC1 please visit the download page, Windows binaries can be found on windows.php.net/qa/. Note that our release candidate cycle is only meant to bug fixes, no more features will be added to PHP 5.5 from now. Please help us to identify bugs in order to ensure that the release is solid and all things behave as expected. Please test this release candidate against your code base and report any problems that you encounter to the QA mailing list and/or the PHP bug tracker. We would like to thank all people helping us making PHP better by testing it and reporting problems, as well as all its contributors for their great work on this 5.5 version of PHP.
Categories: Open Source, PHP Community

PHP 5.4.15 and PHP 5.3.25 released!

Planet-PHP - Thu, 09/05/2013 - 00:00
The PHP development team announces the immediate availability of PHP 5.4.15 and PHP 5.3.25. These releases fix about 10 bugs aswell as upgrading the bundled libmagic library. All users of PHP are encouraged to upgrade to PHP 5.4.15.For source downloads of PHP 5.4.15 and PHP 5.3.25 please visit our downloads page, Windows binaries can be found on windows.php.net/download/.The list of changes are recorded in the ChangeLog.
Categories: Open Source, PHP Community

Christopher Martinez: Static code analysis tools for PHP

PHPDeveloper.org - Wed, 08/05/2013 - 19:38

Christopher Martinez has a recent post to his site that covers some of the static analysis tools available for PHP including the PHP Mess Detector, PHP CodeSniffer and the PHP Analyzer.

I believe in writing code that is easy to understand, easy to test, and easy to refactor. Yes, I realize that the statement above is pretty general and open to interpretation. Not everyone needs external tools to ensure quality in their code...but, I work on things from time to time that have absolutely no tests. [...] For whatever reason, this happens a lot more frequently in the PHP world. I'm guilty of not writing tests and checking how I write code, sometimes, too. Things are bright, though, for the PHP community - for quite some time now, we've had fantastic tools that assist us in writing better code.

He covers each of the tools, talks some about what they're good for and gives examples of their use, including output. He also talks some about the Pfff set of tools created by Facebook. He also talks some about how these tools fit into his daily work as a part of his pre-commit hooks in git.

Link: http://chrsm.org/2013/05/05/code-analysis-tools-for-php
Syndicate content