Advertisement:
Faster SMF BBCode Parser
Navigation
Search
SMF Mod Site
- Mod Name:
- Faster SMF BBCode Parser
- Created By:
- dougiefresh
- Type:
- Feature Enhancement
- First Created:
- July 31, 2015, 09:16:34 AM
- Last Modified:
- August 19, 2015, 07:32:11 PM
- Latest Version:
- 1.1
- Compatible With:
- 2.0.10
- Total Downloads:
- 30
Download this mod
Description:
Introduction
The SMF parser in the SMF 2.0.x line, as well as the SMF 2.1 Beta 1 & 2, have a potentially "fatal flaw", at least where it concerns bbcodes with a large number of parameters. The original SMF code generates permutations of all possible combinations of the parameters in order to make it easier for the user to use bbcodes, and then checks to see which permutation is the right one. A bbcode with 14 parameters generates 98,306 permutations, taking little more than half a second on my system PER USE and using 90MB of memory!! Checking for 15 parameters crashes my forum with an out-of-memory error because it attempts to allocate more than 128MB of memory!
My solution to this issue has several steps:
(1) Internally rearrange the parameters into the proper order and return the number of unused parameters, as well as the replacement string.
(2) If there are unused parameters, then this can't be the bbcode we're looking for. Continue to next bbcode...
(3) TEST the replacement string to see if the parameters match what that particular bbcode expects.
(4) If STEP 3 is not a match, continue to next bbcode...
(5) Replace the bbcode in question with the rearranged version.
Why is this important? Several reasons:
(1) Memory is saved by not having to generate all possible permutations of a particular parameter set.
(2) Time is saved (at least with larger sets) by NOT having to generate a large number of permutations.
(3) Time is saved (at least with larger sets) by NOT having to test a large number of permutations.
(4) Irritation by the user because they don't have to deal with "blank screens of death" due to out-of-memory situations.
Please note that this mod leaves the permute function in place, as other mods or future forum versions may need the built-in functionality.
Related Discussion
o REPORT: Potentially "Fatal Flaw" in SMF's bbcode parser
Admin Settings
There are no admin settings to this mod. To disable, you must uninstall this mod.
Compatibility Notes
This mod was tested on SMF 2.0.10, but should work on SMF 2.0 and up. SMF 1.x is not and will not be supported.
Changelog
The changelog has been removed and can be seen at XPtsp.com.
License
Copyright (c) 2015, Douglas Orend
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.