Changeset 1681
- Timestamp:
- 12/12/2007 08:04:09 PM (13 months ago)
- Location:
- trunk/scripts
- Files:
-
- 2 modified
-
stringparser.class.php (modified) (2 diffs)
-
stringparser_bbcode.class.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/scripts/stringparser.class.php
r1624 r1681 7 7 * upon this class. 8 8 * 9 * Version: 0.3. 19 * Version: 0.3.2 10 10 * 11 11 * @author Christian Seiler <spam@christian-seiler.de> … … 13 13 * @package stringparser 14 14 * 15 * This program is free software; you can redistribute it and/or modify 16 * it under the terms of either: 15 * The MIT License 17 16 * 18 * a) the GNU General Public License as published by the Free 19 * Software Foundation; either version 1, or (at your option) any 20 * later version, or 17 * Copyright (c) 2004-2007 Christian Seiler 21 18 * 22 * b) the Artistic License as published by Larry Wall, either version 2.0, 23 * or (at your option) any later version. 19 * Permission is hereby granted, free of charge, to any person obtaining a copy 20 * of this software and associated documentation files (the "Software"), to deal 21 * in the Software without restriction, including without limitation the rights 22 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 23 * copies of the Software, and to permit persons to whom the Software is 24 * furnished to do so, subject to the following conditions: 24 25 * 25 * This program is distributed in the hope that it will be useful, 26 * but WITHOUT ANY WARRANTY; without even the implied warranty of 27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either 28 * the GNU General Public License or the Artistic License for more details. 26 * The above copyright notice and this permission notice shall be included in 27 * all copies or substantial portions of the Software. 29 28 * 30 * You should have received a copy of the Artistic License with this Kit, 31 * in the file named "Artistic.clarified". If not, I'll be glad to provide 32 * one. 33 * 34 * You should also have received a copy of the GNU General Public License 35 * along with this program in the file named "COPYING"; if not, write to 36 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 37 * MA 02111-1307, USA. 29 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 35 * THE SOFTWARE. 38 36 */ 39 37 -
trunk/scripts/stringparser_bbcode.class.php
r1624 r1681 3 3 * BB code string parsing class 4 4 * 5 * Version: 0.3. 15 * Version: 0.3.2 6 6 * 7 7 * @author Christian Seiler <spam@christian-seiler.de> … … 9 9 * @package stringparser 10 10 * 11 * This program is free software; you can redistribute it and/or modify 12 * it under the terms of either: 11 * The MIT License 13 12 * 14 * a) the GNU General Public License as published by the Free 15 * Software Foundation; either version 1, or (at your option) any 16 * later version, or 13 * Copyright (c) 2004-2007 Christian Seiler 17 14 * 18 * b) the Artistic License as published by Larry Wall, either version 2.0, 19 * or (at your option) any later version. 15 * Permission is hereby granted, free of charge, to any person obtaining a copy 16 * of this software and associated documentation files (the "Software"), to deal 17 * in the Software without restriction, including without limitation the rights 18 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 19 * copies of the Software, and to permit persons to whom the Software is 20 * furnished to do so, subject to the following conditions: 20 21 * 21 * This program is distributed in the hope that it will be useful, 22 * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either 24 * the GNU General Public License or the Artistic License for more details. 22 * The above copyright notice and this permission notice shall be included in 23 * all copies or substantial portions of the Software. 25 24 * 26 * You should have received a copy of the Artistic License with this Kit, 27 * in the file named "Artistic.clarified". If not, I'll be glad to provide 28 * one. 29 * 30 * You should also have received a copy of the GNU General Public License 31 * along with this program in the file named "COPYING"; if not, write to 32 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 33 * MA 02111-1307, USA. 25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 28 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 30 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 31 * THE SOFTWARE. 34 32 */ 35 33 … … 773 771 */ 774 772 function _openElement ($type = 0) { 775 $name = $this->_topNode ('name'); 776 if (!isset ($this->_codes[$name])) { 777 if (isset ($this->_codes[strtolower ($name)]) && (!$this->getCodeFlag (strtolower ($name), 'case_sensitive', 'boolean', true) || !$this->_caseSensitive)) { 778 $name = strtolower ($name); 779 } else { 780 return $this->_reparseAfterCurrentBlock (); 781 } 773 $name = $this->_getCanonicalName ($this->_topNode ('name')); 774 //var_dump ($name); 775 if ($name === false) { 776 return $this->_reparseAfterCurrentBlock (); 782 777 } 783 778 $occ_type = $this->getCodeFlag ($name, 'occurrence_type', 'string'); … … 926 921 */ 927 922 function _isOpenableWithClose ($name, &$closecount) { 928 $tnname = $this->_topNode ('name'); 929 if (isset ($this->_codes[strtolower($tnname)]) && (!$this->getCodeFlag (strtolower($tnname), 'case_sensitive', 'boolean', true) || !$this->_caseSensitive)) { 930 $tnname = strtolower($tnname); 931 } 923 $tnname = $this->_getCanonicalName ($this->_topNode ('name')); 932 924 if (!in_array ($this->getCodeFlag ($tnname, 'closetag', 'integer', BBCODE_CLOSETAG_IMPLICIT), array (BBCODE_CLOSETAG_FORBIDDEN, BBCODE_CLOSETAG_OPTIONAL))) { 933 925 return false; … … 991 983 */ 992 984 function &_findNamedNode ($name, $searchdeeper = false) { 993 $lname = strtolower ($name); 994 if (isset ($this->_codes[$lname]) && (!$this->getCodeFlag ($lname, 'case_sensitive', 'boolean', true) || !$this->_caseSensitive)) { 995 $name = $lname; 996 $case_sensitive = false; 997 } else { 998 $case_sensitive = true; 985 $lname = $this->_getCanonicalName ($name); 986 $case_sensitive = $this->_caseSensitive && $this->getCodeFlag ($lname, 'case_sensitive', 'boolean', true); 987 if ($case_sensitive) { 988 $name = strtolower ($name); 999 989 } 1000 990 $scount = count ($this->_stack); … … 1343 1333 */ 1344 1334 function _isUseContent (&$node, $check_attrs = false) { 1345 $name = strtolower($node->name ()); 1335 $name = $this->_getCanonicalName ($node->name ()); 1336 // this should NOT happen 1337 if ($name === false) { 1338 return false; 1339 } 1346 1340 if ($this->_codes[$name]['callback_type'] == 'usecontent') { 1347 1341 return true; … … 1370 1364 } 1371 1365 return !$result; 1366 } 1367 1368 /** 1369 * Get canonical name of a code 1370 * 1371 * @access protected 1372 * @param string $name 1373 * @return string 1374 */ 1375 function _getCanonicalName ($name) { 1376 if (isset ($this->_codes[$name])) { 1377 return $name; 1378 } 1379 $found = false; 1380 // try to find the code in the code list 1381 foreach (array_keys ($this->_codes) as $rname) { 1382 // match 1383 if (strtolower ($rname) == strtolower ($name)) { 1384 $found = $rname; 1385 break; 1386 } 1387 } 1388 if ($found === false || ($this->_caseSensitive && $this->getCodeFlag ($found, 'case_sensitive', 'boolean', true))) { 1389 return false; 1390 } 1391 return $rname; 1372 1392 } 1373 1393 } … … 1813 1833 function &_findPrevAdjentTextNodeHelper () { 1814 1834 $lastnode =& $this->lastChild (); 1815 if ($lastnode ->_type == STRINGPARSER_NODE_TEXT) {1835 if ($lastnode === null || $lastnode->_type == STRINGPARSER_NODE_TEXT) { 1816 1836 return $lastnode; 1817 1837 }
