Category: Web

Introduction

While I was writing the footnotes plugin for b2evolution, I discovered a loophole, or rather, ambiguity, in the HTML 4.01 specification which causes a lot, if not all, browsers to behave incorrectly. It has something to do with the <base> tag and how self-referencing anchor/URI fragments are resolved.

What is the base tag? According to the W3’s HTML 4.01 specification here, the base tag “specifies an absolute URI that acts as the base URI for resolving relative URIs.” So if you have index.html in www.yourserver.com and index.html has his:

HTML:


<head>
    <base href="www.yahoo.com" />
</head>
<body>
    <img src="/image.jpg" />
….

image.jpg would get resolved to www.yahoo.com/image.jpg instead of www.yourserver.com/image.jpg. This is how the “Save webpage” feature of html browsers manipulate relative URIs

Now what about self-referencing anchors/fragments? Well, everyone knows anchors. They’re basically go like. <a name="anchor_a">foo</a> which could be referenced on the same page using <a href="#anchor_a">bar</a>. The text after the crosshatch (#) sign is called the fragment identifier the entire thing is called, logically, a same-document reference. If you specify a URI before the fragment identifier (e.g. <a href="www.something.com/index.html#anchor_a">), instead of the link taking you to the anchor on the same page, it will take you to the anchor of that URI (another page). More information can be found in the RFC 2396.

The Ambiguity

Now we know that if a fragment doesn’t contain any URI before it, it is meant to refer to the same document. Now the problem: where should those same-document reference point to when the base is changed using the base tag? Should they still point to the document or should they point to the anchor of the document located at the base URI or should they do something else? Keep in mind how same-document references are being used.

Read more »

Another update. This time, it’s in order to support versions prior to 1.10.x which don’t support item filtering. So, for compatibility, the option of using bbcode syntax (i.e. [footnote note="foo"]bar[/footnote]) is added (make sure it’s enabled at the plugin settings first before using). This update is only necessary for those using 1.9.3 and below. The old version can still be used for those who are using 1.10.x.

Link (version 0.2)

Important note:

When using the alternate syntax mixing both syntaxes especially nesting them will cause undefined behavior this only applies to users version 1.10.x who turned on the alternate syntax opti

I discovered a small programming mistake this morning involving a misnamed variable (because PHP doesn’t detect nonexistent variables until it actually encounters it). I fixed it and the updated one is already uploaded here. I also added a note after installation reminding the user to add the footnotes classes to the stylesheets.

Update #2

I discovered another stupid typo which causes the syntax matching to fail. Also, I fixed a bug where the note parameter gets duplicated everytime a post with footnotes gets edited. The updated one is already posted. Please use this update immediately instead of the previous one.

Get it here:

The footnotes plugin ease the creation of footnotes with the following formats: tooltips such as this and anchor links such as this1. Adding those footnotes is as easy as using:

HTML:

<footnote note="Header::Footnote goes here">Main Text</footnote>

Note: b2evolution version < 1.10

Make sure that you turn on “Use Alternate Syntax” which follows the bbcode conventions (i.e. [footnote note="hello"]world[/footnote])

To install, just unzip the entire folder to your plugins directory and follow the readme.html inside.

b2evolution version ≥ 1.10.3 Note

The Auto P plugin of b2evolution 1.10.3 (including the 2.x releases) has been modified which paragraph-breaks ALL HTML comments including the meta-comments used by the footnotes plugin. Line 105 of [blogroot]/plugins/_auto_p.plugin.php has to be modified from:

PHP:

// Handle blocks, splitted by comments. This includes especially the "meta-comments"
// ("<!–more–>", "<!–nextpage–>" or "<!–noteaser–>"):
$content_parts = preg_split( ‘~(<!–.*?–>)~s’, $content, -1, PREG_SPLIT_DELIM_CAPTURE);
$content_parts[] = ‘’;

to

PHP:

// Handle blocks, splitted by comments. This includes especially the "meta-comments"
// ("<!–more–>", "<!–nextpage–>" or "<!–noteaser–>"):
$content_parts = preg_split( ‘~(<!–(?:more|nextpage|noteaser)–>)~s’, $content, -1, PREG_SPLIT_DELIM_CAPTURE);
$content_parts[] = ‘’;

More information can be read from the documentation.

Footnotes

1This is a footnote too

Wil
01/06/07

GeSHi Plugin Updated

The GeSHi Plugin has been updated. It just comprises of minor fixes but the notable ones are the removal of the XHTML settings and the addition of the strict parameter. They are:

  • The regular expressions used for parsing the code tags are more lenient (i.e. they allow line breaks in the middle of the tag
  • Removed unused methods (due to the switch to GeSHi)
  • Removed the XHTML Strict Setting (since it’s not used)
  • Added strict parameter (same as the strict option in GeSHi). Example:

    HTML:

    <codeblock lang="php" strict="true"><codeblock>

    And the default value is false

  • Did some changes to the plugin information (version and author)

As usual, you can grab it here.

1 2 >>