Node titles containing a questionmark (?) or possibly other special characters are not being replaced by the freelinking module.

I don't know much about how to use CVS, so this is my fix (inserting function preg_quote):

    case 'process':
// FIXME ***
      $camelcaseregexp = '/\b([[:upper:]][[:lower:]]+){2,}\b/'; // this gets us close, but is not perfect. Example: ThisIsACamelCaseWord won't match (two caps in a row)
      preg_match_all($camelcaseregexp, $text, $ccmatches);
      $freelinkingregexp = '/\[\[.+]]/U'; // this finds [[links like this]], un-greedily
      preg_match_all($freelinkingregexp, $text, $flmatches);
      $wikiwords = array_merge($ccmatches[0], $flmatches[0]);
      foreach (array_unique($wikiwords) as $wikiword) {
        if (substr($wikiword, 0, 2) == '[[') { // if it's a freelink, the expressions are different
          $phrase = substr($wikiword, 2, -2);
          $pattern = '/\[\[' . preg_quote($phrase) . ']]/';
          $replacement = l($phrase, 'freelinking/' . rawurlencode(htmlspecialchars(rawurlencode($phrase))));
        }
        else { // it's a CamelCase, expressions are a bit simpler
          $pattern = '/\b' . preg_quote($wikiword) . '\b/';
          $replacement = l(preg_quote($wikiword), 'freelinking/' . urlencode($wikiword));
        }
        $text = preg_replace($pattern, $replacement, $text);
      }
      return $text;
      break;

changed lines are:

          $pattern = '/\[\[' . preg_quote($phrase) . ']]/';

and:

          $pattern = '/\b' . preg_quote($wikiword) . '\b/';

and:

          $replacement = l(preg_quote($wikiword), 'freelinking/' . urlencode($wikiword));

Sorry again for not using CVS.

Comments

eafarris’s picture

Version: 4.5.x-1.x-dev » 4.6.x-1.x-dev
Assigned: stratofarmer » eafarris
Status: Needs review » Fixed

Should be fixed along with #42386, implementing a fix remarkably similar to yours. Thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)