added support for angstrom and protection against magic_quotes_runtime (feedback from Alexander Refsum Jensenius)

This commit is contained in:
Martin Monperrus
2011-12-11 22:40:23 +01:00
parent 7f23eca401
commit 7dc3b2ebbd
+15 -1
View File
@@ -378,12 +378,21 @@ define('BIBTEXBROWSER','v__MTIME__');
@error_reporting(/*pp4php:serl*/E_ALL/*lres*/); @error_reporting(/*pp4php:serl*/E_ALL/*lres*/);
/** sets the database of bibtex entries (object of type BibDataBase) /** sets the database of bibtex entries (object of type BibDataBase)
* in $_GET[Q_DB] * in $_GET[Q_DB]
* Uses a caching mechanism on disk for sake of performance * Uses a caching mechanism on disk for sake of performance
*/ */
function setDB() { function setDB() {
// Check if magic_quotes_runtime is active
if(get_magic_quotes_runtime())
{
// Deactivate
// otherwise it does not work
set_magic_quotes_runtime(false);
}
// default bib file, if no file is specified in the query string. // default bib file, if no file is specified in the query string.
if (!isset($_GET[Q_FILE]) || $_GET[Q_FILE] == "") { if (!isset($_GET[Q_FILE]) || $_GET[Q_FILE] == "") {
?> ?>
@@ -891,6 +900,10 @@ function latex2html($line) {
// added && strpos($line,'{')===false // added && strpos($line,'{')===false
if (strpos($line,'\\')===false && strpos($line,'{')===false) return $line; if (strpos($line,'\\')===false && strpos($line,'{')===false) return $line;
// we should better replace this before the others
// in order not to mix with the HTML entities coming after (just in case)
$line = str_replace('\\&','&', $line);
// handling \url{....} // handling \url{....}
// often used in howpublished for @misc // often used in howpublished for @misc
$line = preg_replace('/\\\\url\{(.*)\}/U','<a href="\\1">\\1</a>', $line); $line = preg_replace('/\\\\url\{(.*)\}/U','<a href="\\1">\\1</a>', $line);
@@ -942,7 +955,8 @@ function latex2html($line) {
$line = str_replace('\\o','&oslash;', $line); $line = str_replace('\\o','&oslash;', $line);
$line = str_replace('\\O','&Oslash;', $line); $line = str_replace('\\O','&Oslash;', $line);
$line = str_replace('\\&','&amp;', $line); $line = str_replace('\\aa','&aring;', $line);
$line = str_replace('\\AA','&Aring;', $line);
// clean out extra tex curly brackets, usually used for preserving capitals // clean out extra tex curly brackets, usually used for preserving capitals
$line = str_replace('}','', $line); $line = str_replace('}','', $line);