Drop Task: Add a link component to flexifilter module

cwgordon7 - February 5, 2008 - 00:12
Project:Flexifilter
Version:6.x-1.1-rc1
Component:Code - Components
Category:task
Priority:normal
Assigned:cwgordon7
Status:needs work
Description

The flexifilter module is a powerful site-building tool. However, one thing that it's missing is a link component. Instead of using a link component, current flexifilters have to do complicated, slightly hackish stuff, such as prepending <a href="... etc. Instead, a link component would provide an easy, clean way of doing this.

Basic description:

Should be able to parse links in the form of either: link|title or title|link

Should not have "|" locked in as the divider; rather, it should be admin-specified.

Should be able to parse empty titles such as simply link into links such as <a href="link">link</a>

Should not attempt to make a link on an empty() link unless admin-specified.

Admin should be able to specify a prefix for the links; for example, http://en.wikipedia.org/wiki/

Deliverables:

A patch against flexifilter.components.inc.

Mentor:

cwgordon7

#1

cwgordon7 - March 1, 2008 - 01:08
Assigned to:Anonymous» cwgordon7
Status:active» needs review
AttachmentSize
flexifilter_link_01.patch 12.55 KB

#2

Amitaibu - March 16, 2008 - 19:22
Status:needs review» needs work

Patch fails agains 6.x-1.1-rc1:

$ patch -p0 < flexifilter_link_01.patch
patching file flexifilter.components.inc
Hunk #2 FAILED at 666.
Hunk #3 FAILED at 828.
2 out of 3 hunks FAILED -- saving rejects to file flexifilter.components.inc.rej

patching file flexifilter.flexifilters.inc

#3

cwgordon7 - March 16, 2008 - 20:05
Status:needs work» needs review

Applicable to CVS HEAD, please.

#4

Amitaibu - March 16, 2008 - 20:21
Status:needs review» needs work

Minor bug:
The delimiter doesn't appear by default.

bigger bug:

original content
--------------
[[hello|hello]]

[hello|hello]

filtered content (appears as link)
--------------

hello]]</p> <p>[hello|hello]</p>

export
-------
a:8:{s:5:"label";s:4:"Test";s:11:"description";s:11:"just a test";s:2:"id";s:1:"2";s:7:"enabled";b:1;s:8:"advanced";b:0;s:5:"delta";s:1:"1";s:10:"components";a:3:{i:0;a:3:{s:5:"class";s:26:"flexifilter_link_component";s:8:"settings";a:6:{s:8:"ordering";s:1:"0";s:7:"divider";s:1:"|";s:8:"no_links";i:0;s:10:"check_path";i:0;s:6:"prefix";s:0:"";s:4:"step";s:7:"process";}s:2:"id";s:2:"94";}s:7:"id_next";i:95;s:9:"id_prefix";s:22:"flexifilter_component_";}s:3:"fid";s:3:"new";}

#5

cwgordon7 - March 17, 2008 - 01:06
Status:needs work» needs review

You need to wrap it within a chunk grabber for anything useful to happen. What's happening here looks like a strange combination of a naive use of flexifilter with the line break filter.

#6

Amitaibu - March 17, 2008 - 07:21
Status:needs review» needs work

The minor bug is still there - "The delimiter doesn't appear by default" (i.e. I get a drupal error message "Divider field is required.")

#7

Amitaibu - March 17, 2008 - 13:47

Another strange issue I get, although I must admit I'm still somewhere on the learning curve of this module :)

original preview:
this is a '''test'''

Component: Linkifier:
<a href="/D6/?q=this%20is%20a%20%3Cstrong%3Etest%3C/strong%3E">this is a &lt;strong&gt;test&lt;/strong&gt;</a>

attached flexifilter export.

AttachmentSize
export.txt 1.54 KB

#8

florisla - February 5, 2009 - 15:09

Amitaibu, for #7: The double quotes around 'test' are apparently being used to give the text a bold layout using the HTML 'strong' tag. So another filter (flexifilter component?) is interfering here.

This is the explanation:

In URL encoding (used in the href), the html brackets < and > are encoded as %3C and %3E. In HTML encoding (used between the 'a' tags), they are encoded as < and >. Similarly, spaces are URL encoded as %20.

#9

florisla - February 15, 2009 - 11:15

Here is a modified version of the patch in #1 above.

Changes:

  • Applicable to 6.x-1.1-rc2 (latest released version)
  • Bugfix: form default values did not appear (the minor bug in #4 above)
  • Bugfix: characters in URL were not urlencode()d, giving html syntax errors for links containing double quotes.
  • Feature: integration with pathauto module trough extra option 'pathauto cleanup' (only available when pathauto module is active). This will transform the link to conform to pathauto's rules.
  • Code style: replaced nested if block with one if ( x && y) block.

Still to investigate:

  • Cannot set default value TRUE for a checkbox, since isset() always returns false when the user de-selects it, and then the default value is applied once again. Result: default value TRUE makes it impossible to set it to FALSE.
  • Chunk grabber does not do a good job at parsing chunks that contain chunk delimiters in their content. Case in point: "[link [1] before [otherlink]".
  • Cross-site scripting: investigate if there is no vulnerability

This component is now in use on an experimental Drupal install of mine, using the following filter:

a:9:{s:5:"label";s:9:"Wiki link";s:11:"description";s:67:"Transforms [links] into hyperlinks, supporting [alternative|names].";s:2:"id";s:2:"18";s:7:"enabled";b:1;s:8:"advanced";b:0;s:5:"delta";s:1:"0";s:5:"cache";s:1:"1";s:10:"components";a:3:{i:0;a:3:{s:5:"class";s:22:"flexifilter_chunk_grab";s:8:"settings";a:7:{s:6:"starts";s:1:"[";s:4:"ends";s:1:"]";s:11:"pass_limits";i:0;s:14:"case_sensitive";i:0;s:12:"include_rest";i:1;s:4:"step";s:7:"process";s:10:"components";a:1:{i:0;a:3:{s:5:"class";s:26:"flexifilter_link_component";s:8:"settings";a:7:{s:8:"ordering";s:1:"0";s:7:"divider";s:1:"|";s:8:"no_links";b:0;s:10:"check_path";i:1;s:16:"pathauto_cleanup";i:1;s:6:"prefix";s:5:"wiki/";s:4:"step";s:7:"process";}s:2:"id";s:2:"91";}}}s:2:"id";s:2:"89";}s:7:"id_next";i:92;s:9:"id_prefix";s:22:"flexifilter_component_";}s:3:"fid";s:3:"new";}

AttachmentSize
flexifilter_link_02.patch 13.36 KB
 
 

Drupal is a registered trademark of Dries Buytaert.