laogeodritt
Forum Replies Created
-
Hi Hannah,
Thanks for the response. The page affected is http://ieee.concordia.ca/events, which currently shows “Zymology…” first and ends with “Arduino”.
In case any of these options are relevant to the issue, the Portfolio Page options are: Four Column / Order By==Title / Items per Page==All. Portfolio Work Types is set to our Events type, and other fields are blank/No/unchecked.
Also, the topic post form asks for WordPress version but as I’m noticing this isn’t very visible, I’ll just note here that I’m using WordPress 4.4.1.
Thanks,
Best regards,
Marc-Alexandre Chan
Forum: Themes and Templates
In reply to: [Virtue] Regex bugs in kadence_addlightboxrel()A couple variations on my test cases earlier could get caught up with the linked article’s regex. Since it’s more specific, it’s less likely to happen “in the wild”, but the same idea of “the tag doesn’t match, but
(.*?)can match the closing of a tag and opening of a new one” applies.The code in the linked article adds the
relafter the detectedhref/anchor file type. This position is important to determine what cases will not quite match properly but substitute properly, versus those that will actually fail.<a href="(.*?).(jpg|jpeg|png|gif|bmp|ico)"><img(.*?)class="(.*?)wp-image-(.*?)" \/><\/a>A few examples:
<a href="/not/an/image">text</a> more text... later on, an <a href="/image.jpg"><img src="/wp-content/upload/blah.jpg" class="wp-image-111" /></a>– this one technically matches ALL of this text (which is not correct), but still works because therelgets added to the end of the second<a>opening tag.<a href="/image.jpg"><img src="image.jpg" /></a> shouldn't be lightboxed (the img doesn't have a class) but is, and then later there's <a href="/image2.jpg"><img src="/image2.jpg" class="wp-image-111" /></a> one of these that should be lightboxed but isn't.<a href="/image.jpg"><img src="image.jpg" class="not-the-right-class" /></a> shouldn't be lightboxed (the img has the wrong class) but is, and then later there's <a href="/image2.jpg"><img src="/image2.jpg" class="wp-image-111" /></a> one of these that should be lightboxed but isn't.You can find another example that forces the last
(.*?)to match too widely again. The “simple” (but again not 100%) solution to fix this kind of regex would be to use a character class instead of the dot: for example, if you’re inside quotation marks,([^"]*?)would cover a much larger number of situations (since it can never match outside the ending quotation mark). If you’re inside an HTML tag,([^>]*?)will never go beyond the tag’s end (but if an attribute value contains a>, which is valid IIRC for some attributes, this one will break).Also note that this regex does not match single quotes around an attribute value, which are valid in HTML5.
I would honestly recommend not matching only “wp-image-*” classes, though, as power users may write their own markup or include images uploaded elsewhere via FTP, rather than necessarily use the Media Manager. (For example, I personally use the Media Manager for images included in blog posts, but I manually upload images that go into Pages so I can better organize them, while still wanting the lightbox plugin to affect it.)
As for the backtrack limit, honestly it’s not very likely for most users, since the default is 100,000 (kind of low, but not going to be hit unless someone has a gigantic article), and in I think PHP 5.3+ it’s 1 or 10 million (probably not even a concern for any realistic article size). It’s good practice to catch errors if they do happen (as in my case), but the low backtrack limit was just an oversight on my part when I was editing the php.ini settings.
For the error,
trigger_errorwith a warning might be good enough for technically experienced WordPress/PHP users. However, if you can somehow report it on the page or in the admin panel (and take measures so that the error doesn’t break that page entirely), that’d probably be better for the majority of users.Best regards,
Laogeodritt
Forum: Themes and Templates
In reply to: [Virtue] Regex bugs in kadence_addlightboxrel()Hi,
Hope the length wasn’t too tedious! I figured since I had done the investigations/attempted patches, might as well document it in case it’s useful for you.
Like I mentioned, the major issue we had was a php.ini problem (too low backtrack limit), that caused posts to disappear off the page. Maybe one improvement for the Virtue theme would be that whenever
preg_matchorpreg_replaceare called, check if errors occurred by callingpreg_last_error()and log those issues? (They don’t get logged to the error log by default.)Otherwise for the regex itself, I guess a lot of the failure cases are edge cases, and half of them will work anyway despite technically failing to match correctly (depends on if the “wrong” matched tag is first or last, since
relgets added at the end). It’s not exactly a blocker, but not too improbable to hit a bug in the wild.As for the DOM option, I’m really surprised at how bad PHP’s implementation of the DOM parser is pre-5.4, and admittedly I don’t know how badly it can affect performance (a high-traffic site should be using caching though anyway).
Just to note, also, that in the linked article,
(.*?)will likely have the same problem as it did here. That capture group is quite a dangerous one for capturing unexpected text!Best regards,
Laogeodritt
Hi Nick, thanks for the reply. (Oops, did I get your name wrong earlier? Looking back I have no idea where I got ‘Phil’ from. Sorry!)
The problem in the linked thread is an add to Google/iCal export for each independent event (where the Event Builder can be used). In this case we’d like to just link to the Calendar as a whole, to add our calendar to the user’s own list of calendars (“Other Calendars” on the GCal page).
Like I mentioned, we have it working with an external text widget for the sidebar containing a link, and just a manual link on the pages that contain the calendar shortcode. This solution is fine for us.
I mentioned this as a feature request because I thought it might be a nice convenience, and one that may be useful to a good proportion of users, to have it as an option to automatically generate that link before/after the events display (calendar, list, etc.) itself, rather than placing it manually.
Regards,
Laogeodritt
Forum: Plugins
In reply to: [Plugin: Google XML Sitemaps] Sitemap ErrorPlease take a look at the source of your sitemap — everything seems to be in order.
Forum: Fixing WordPress
In reply to: How to change table prefixI think that the security benefits are minimal but existent. Somebody could sensibly still exploit an SQL Injection vulnerability, but were he able to execute MySQL queries freely, he wouldn’t be able to select tables without knowing the prefix. I’m neither a security expert nor am I knowledgeable with common web cracking techniques, so I’m not entirely sure, though.
As for changing the prefix:
If you ONLY changed the table prefix, then WordPress tries to find tables called asdf_(something) in your database, but they’re still all called wp_(something). You have to change the table’s prefixes themselves too (in phpMyAdmin or similar).
you can run
RENAME TABLE (old_table) TO (new_table)
in your case, for example,RENAME TABLE wp_comments TO asdf_commentsAnd repeat for each of the ten tables in your WordPress database.
But! If you try going into your Admin panel now, you’ll get an error. This is because there’s certain rows that need changing, because they contain the prefix too. (From http://www.eligeotravez.net/2007/04/17/changing-table-prefix-for-wordpress/ )
Table (prefix)_options
–> option_name = (old prefix)_user_roles
Table (prefix)_usermeta
–> meta_key = (old prefix)_capabilities
–> meta_key = (old prefix)_user_level
–> meta_key = (old prefix)_autosave_draft_idsThe last one might not exist, depending on whether you autosaved a draft in WordPress or not. Anyway, what I did when I did this was use phpMyAdmin, select the table in question, go to the SQL tab, and run these commands:
UPDATE (new prefix)_options SET option_name = '(new prefix)_user_roles' WHERE option_name = '(old prefix)_user_roles'UPDATE (new prefix)_usermeta SET ,eta_key = '(new prefix)_capabilities' WHERE meta_key = '(old prefix)_capabilities'And so on, where (new prefix) and (old prefix) are these prefixes, without the parentheses of course. This will update all of those values.