more lang and safe search tweaks, a=chris
more lang and safe search tweaks, a=chris
diff --git a/src/library/LocaleFunctions.php b/src/library/LocaleFunctions.php
index d126431df..e5918c881 100755
--- a/src/library/LocaleFunctions.php
+++ b/src/library/LocaleFunctions.php
@@ -200,8 +200,8 @@ function guessLangEncoding($encoding)
function guessEncodingHtmlXml($html, $return_loc_info = false)
{
// first try for XML encoding info
- preg_match("/\<\?xml[^\?]+encoding\=[\'\"](.+)[\'\"][^\?]+\?\>/",$html,
- $matches, PREG_OFFSET_CAPTURE);
+ preg_match("/\<\?xml[^\?]+encoding\=[\'\"]\s*(\S+)\s*[\'\"][^\?]+\?\>/",
+ $html, $matches, PREG_OFFSET_CAPTURE);
if (!empty($matches[1][1])) {
$encoding = strtoupper($matches[1][0]);
$start_charset = $matches[1][1];
diff --git a/src/library/processors/HtmlProcessor.php b/src/library/processors/HtmlProcessor.php
index 9239876af..8e7c2b1dd 100755
--- a/src/library/processors/HtmlProcessor.php
+++ b/src/library/processors/HtmlProcessor.php
@@ -252,6 +252,7 @@ class HtmlProcessor extends TextProcessor
$lang = (empty($lang)) ? null : $lang;
foreach ($htmls as $html) {
$lang = $html->getAttribute('lang');
+ $lang = str_replace("_", "-", $lang);
if ($lang != null && $lang != 'en' && $lang != 'en-US') {
return $lang;
}
diff --git a/src/models/PhraseModel.php b/src/models/PhraseModel.php
index 4c8da6e0c..be576beec 100755
--- a/src/models/PhraseModel.php
+++ b/src/models/PhraseModel.php
@@ -1567,8 +1567,8 @@ class PhraseModel extends ParallelModel
$disjunct .= " lang:" . $lang_parts[0];
}
if (!stristr($disjunct, "safe:")) {
- $disjunct .= (empty($_SESSION['safe'])) ?
- " safe:true" : " safe:" . $_SESSION['safe'];
+ $disjunct .= (empty($_SESSION['SAFE_SEARCH'])) ?
+ " safe:true" : " safe:" . $_SESSION['SAFE_SEARCH'];
}
}
$out_query .= $pipe . $disjunct;