mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-05 05:37:49 +02:00
[3.1.0] Fixed bug with fallback languages in LanguageFactory
- Also, reverted bogus Generator changes git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1723 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@@ -77,7 +77,7 @@ class HTMLPurifier_Generator
|
||||
'wrap' => 68,
|
||||
), 'utf8');
|
||||
$tidy->cleanRepair();
|
||||
$html = ((string) $tidy); // explicit cast necessary
|
||||
$html = (string) $tidy; // explicit cast necessary
|
||||
}
|
||||
|
||||
// Normalize newlines to system defined value
|
||||
|
@@ -27,6 +27,13 @@ class HTMLPurifier_Language
|
||||
*/
|
||||
public $errorNames = array();
|
||||
|
||||
/**
|
||||
* True if no message file was found for this language, so English
|
||||
* is being used instead. Check this if you'd like to notify the
|
||||
* user that they've used a non-supported language.
|
||||
*/
|
||||
public $error = false;
|
||||
|
||||
/**
|
||||
* Has the language object been loaded yet?
|
||||
* @todo Make it private, fix usage in HTMLPurifier_LanguageTest
|
||||
|
11
library/HTMLPurifier/Language/messages/en-x-testmini.php
Normal file
11
library/HTMLPurifier/Language/messages/en-x-testmini.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
// private language message file for unit testing purposes
|
||||
// this language file has no class associated with it
|
||||
|
||||
$fallback = 'en';
|
||||
|
||||
$messages = array(
|
||||
'HTMLPurifier' => 'HTML Purifier XNone'
|
||||
);
|
||||
|
@@ -104,14 +104,13 @@ class HTMLPurifier_LanguageFactory
|
||||
$lang = new $class($config, $context);
|
||||
} else {
|
||||
// Go fallback
|
||||
$fallback = $this->getFallbackFor($code);
|
||||
// If a language doesn't exist, English's language settings
|
||||
// file will automatically be used, which DOESN'T have any
|
||||
// fallback defined. This is fine for settings merging, but
|
||||
// not so good for figuring out a class to use.
|
||||
if ($fallback === false) $fallback = 'en';
|
||||
$raw_fallback = $this->getFallbackFor($code);
|
||||
$fallback = $raw_fallback ? $raw_fallback : 'en';
|
||||
$depth++;
|
||||
$lang = $this->create($config, $context, $fallback);
|
||||
if (!$raw_fallback) {
|
||||
$lang->error = true;
|
||||
}
|
||||
$depth--;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user