Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by DrQuincy

  1. The title says it all really. When using $sanitizer line() and text() seem the same and lines() and textarea() respectively. I.e. strip_tags() and then if line() or text() remove line returns also. What are the differences? Thanks.
  2. Ah yes, that explains it. It says: I can't help thinking just escaping the string rather than filtering things out (as you would do with standard SQL query) makes more sense.
  3. Aha, I knew there must've been a simpler solution, thanks! I don't know how I missed the whitelist option. After running a few tests, it seems though basically so long as your selector doesn't contain double quotes you can wrap it in double quotes and it will accept anything. And even then you can escape the double quote with a backslash. $selector = '"This is a \"valid\" selector string \'^%$!"'; // This works as is Is there an API function to prepare a string in this way? Unless I'm missing something wouldn't a simpler solution be to have an escapeSelectorValue() type function that adds " to the beginning and the end and escapes double quotes? I'm not being critical, just trying to understand the rationale behind the API. Thanks!
  4. I have thought about this and I think if this is the case there are a few options available: Call wire('sanitizer')->selectorValue() via a hook on save or in the template Limit the characters with regex in the text input disallowing the above Have an extra field that stores the unfiltered text and then have a hidden field that stores a filtered version (managed via hooks); show the unfiltered version in the front end but search via the filtered hidden one (this would mean, using my example, '100' and '$100' are the same when searching) If there aren't going to be loads of options use some kind of enumeration (1=$100, 2=$200) via another template, select options, etc and search the number instead of the value If you are using FULLTEXT search I think this is irrelevant as it ignores these characters anyway (unless using BOOLEAN MODE, does PW support this?). Can someone just confirm though that PW does not support exact match searching with the following? "\\0", "\\", "`", "|", '=', '*', '%', '~', '^', '$', '#', '<', '>', '[', ']', '{', '}', "\r", "\n", "\t" I guess I am thinking about edge cases here as unusually filtered values are simple and anything more complex would be FULLTEXT. Thanks.
  5. Looking at the source and the docs it seems like you can't escape special characters and the following aren't allowed: "\\0", "\\", "`", "|", '=', '*', '%', '~', '^', '$', '#', '<', '>', '[', ']', '{', '}', "\r", "\n", "\t" I guess it doesn't matter so much in a natural language search where these kinds of things are filtered out anyway but where you are finding pages using field=value selectors this could trip you up. Is there a built in way to filter these characters out of a field when you save it so you know when you use exact match selectors on them it will be reliable? E.g. product page with field 'bid' with a value '$100'. I run pages()->find('template=product, bid=' . wire('sanitizer')->selectorValue('$100')). This will fail to find my product won't it as it will looking for ' 100'' not '$100'. I know in the real world you probably wouldn't store the '$' but I am just using this as an example. Or do you just assume that any exact match fields should be more predictable values (e.g. numbers, preset categories) and that anything that allows special characters would only ever be searched by a FULLTEXT index? Thanks.
  6. This might be a silly question but wire('sanitizer')->selectorValue() seems to remove characters like ^ and = rather than escape them. Does that mean you cannot, for example, use pages()->get() to match a field that contains any of these characters? Or is there an escape function I'm missing? I don't actually need (yet) to but I wondered if this was a limitation. If so, what characters are/aren't allowed? E.g. can you can only use a-z-Z0-9'"-_? Thanks. 🙂
  7. A few questions please: If you want full control over the rendered HTML how does it work? Does conditional fields hiding still work via CSS classes? (E.g. if you select x from a drop down field y shows) How effective is the spam prevention if you use this method? Is it easy enough to force the form to render with JavaScript and add a time delay (e.g. the form must've loaded rendered at last 2 seconds ago to pass validation)? If you render the front-end HTML yourself does it still do client-side validation? Does it handle all server-side validation? Can you set the from name and email headers for any emails sent so they are different to the reply to ones? Can you easily hook in custom PHP code on the back end for a) validation and b) processing the form if successful? Thanks.
  8. This is great. I have just added .trim() so that it picks up on href=" javascript:alert('');" too. if (element.attributes.href.trim().substring(0, 11).toLowerCase() === 'javascript:') { Thanks again. 🙂
  9. Fantastic, thanks to you both. This community is excellent. I will look at those plugins but like @MortizLost I favour the KISS approach. And the important point is external tools can not only be more specialist you are always evaluating the final complete HTML document as opposed to whatever the CMS can do. I find in PW, for example, I will have blocks of includes that pull in a list of content from elsewhere in the site tree (such as a list of team members or featured case studies) but anything Yoast-type would have no way of knowing this as the template decides it. Yes, it could pull the HTML via AJAX based on the page's path but this is overkill, in my opinion. Also, these tools make help you pick up on things you've missed but they can't evaluate anything within the context of a wider SEO strategy.
  10. Thanks, I'll give it a go when I am in the office later! Do you think it is odd it allows this by default but disallows it in the link dialog? Is there a reason for it or is it an oversight?
  11. I haven't used WordPress in a long time, I never liked it really for reasons I won't bother going into. One thing that comes up from time to time, not just for PW site but in general, is something like “Will there be something similar to Yoast in my new site?” As a default in PW I add a SEO fieldset with optional meta title, description and H1 (title property from PW is used for meta title and h1 if these fields are not set) with some simple guidelines in the notes on how to fill them out. I understand Yoast has some additional tools that advise on the actual body content (word count, paragraph length, etc). Obviously PW doesn't have this. To be honest, I have always thought things like that are really for making poor SEO become mediocre and they can't do the job of a human and create excellent SEO. Also one of the things I love about PW is that I can let clients build pages on a modular basis (using repeater matrices) as opposed to a single body HTML field and so I do not even know that such tools could effectively evaluate such content since it is assembled dynamically. I have been familiar with SEO since before it was a term and have worked with a lot of pro SEOs and none of them have ever been bothered about having something like Yoast so long as the fields I mentioned above are editable. I may be wrong but Yoast seems to appeal more to those less familiar to SEO. No offence is intended if you are a pro SEO and use Yoast. 🙂 What are your thoughts on this?
  12. I use CKeditor 4, the same as PW, in other projects and have noticed it allows <a href="javascript:alert(document.cookie)">. Does anyone know how I can use config to disallow any hrefs that start with javascript:? It's fine in PW as HTML Purifier seems to catch it but I wondered for other projects. There is an option config.linkJavaScriptLinksAllowed but it only applies to the link dialog. I'm sure it must be doable with regex in config.allowedContent but I'm drawing a blank. Thanks.
  13. From what I can tell if you have a Page Reference field and that links to a page, e.g.: page1.pageReference links to page2 page2 is deleted page1.pageReference now equals null Is there any way here to mimic a MySQL RESTRICT action so that page2 cannot be deleted (and warns you as such in the admin) while there are page fields that point to it? Thanks.
  14. If you have an Images or Files field you can specify the maximum number of items and make it required so you need at least one — but can you set a minimum number of files like you can with a repeater? Thanks.
  15. With ProFields Table is it possible to: Set minimum and maximum row numbers? Make a column required I have checked but can't see anything. Thanks.
  16. A couple of further questions on the core's caching. When you enable the cache on a template (from the Cache tab), what is this actually caching? Does this relate to the generated PHP files in the FileCompiler folder? what are the use cases for this? Unlike the above method which invalidates the cache upon template saving out of the box (default option), if you use $cache->get() do you need to manually clear the cache using hooks if you want cache to be cleared upon page saving? I am assuming so and $cache is pretty much a wrapper for something like PHPFastCache. I could not find anything in the core for MarkupCache in V3. Thanks.
  17. Fantastic, thanks so much! I've also never heard of the Tracy plugin before so will check that out too!
  18. Thanks for all the replies, this place is mega-helpful! @teppo, that is a very detailed response and is much appreciated. Just to be clear, my numbers are from timing the execution of PHP — so from the start of the index.php right through to the end. I am not timing anything network-related. When you say “The doc (HTML) part of a fairly complex site I recently finished takes ~600-900ms” are you referring to the PHP execution time, as I am, or is this how long it takes for your browser to get the whole of the HTML document? Even so, if I add on some time for the request my simple brochureware site is still quick compared to your complex site so it tallies. You've pretty much answered my question then that this is how it is out of the box. That's good to know. Will ProCache automatically disable itself for POST requests (e.g. contact forms)? If you have a template that, for example, polls a third party service using cURL, do you simple just disable ProCache for that template in the admin? Is it possible to try ProCache first or do you need to buy it? I will look at WireCache and MarkupCache, thanks @dragan.
  19. I've done quite a number of PW sites now but have only just started looking at performance. I do a lot of custom work using libraries and have been used to very low PHP execution times as a result. Generally under 50ms with OpCache enabled. On my local MAMP server PW is taking generally over half a second to run. That's fine, it's an iMac and not really made as a web server. It speeds up considerably once I upload to my host where it runs on CentOS and Litespeed using PHP 7.4 with Opcache enabled. I am testing the speed of a small brochureware site, currently only ~20 pages. I have a very simple MVP framework I have added so I can separate getting data from PW from the actual HTML templates. Each template has a presenter that loads data from Models (just classes that get the data from PW and format accordingly). From experience, this simple reflection should not slow PW down — and I don't think it does. On my host server I have compared one a similar custom brochure site to this current PW one. Custom site (no Opcache): ~0.03ms execution time PW site (no Opcache): 0.35 to 0.5ms execution time Custom (with Opcache): ~0.02ms execution time PW (with Opcache): 0.18 to 0.35ms execution time I have broadly split the timings via a few tests: Just running the page — ~30-40ms Starting MVP framework — ~10-20ms Running global function — ~60-100ms (getting global settings from template and a few other bits all just getting data from PW pages) Loading rest of page — ~70-200ms (loads a page with a few fields, one is a repeater with 24 fields including a couple of nested repeaters and a page reference array) So the PHP execution time ranges from 180ms to 350ms when using OpCache on the exact environment I will use for the live site. It is a shared server and times always vary but the company I use have very good hardware and are strict about not overselling their resources so as shared servers go, it's a good one. Template cache seems to makes little-to-no difference. I have a somewhat blinkered view here since I don't use off-the-shelf CMSs very often but is this pretty much the execution time you would expect for a small brochure site? I.e. it's just the overhead you have to accept when using something this powerful. This is not a criticism of PW, I am just wondering if this is the norm and that trying to make it any faster is going to be a waste of my time (assuming I do not have the budget to spend on better hardware, which I don't). I do have one old WordPress site I look after and that seems to average 110ms execution time under the same environment — but I don't think it's a fair comparison since it's a five page site with no plugins installed. From other WP sites I have seen once you add plugins — which you need to do anything half-decent — then it really starts slowing down. Would ProCache make a difference or is this more for high-traffic sites (this site would not be high traffic)? Is ProCache as low maintenance as OpCache or is it easy to end up with stale data in certain contexts? Thanks. 🙂
  20. Another question on ProFields Repeater Matrix… Can each matrix type have its own validation? So if I have “banner” and “list” content types, for example, and the banner has a mandatory image it will only be mandatory if “banner” is chosen and not “list”. Is that how it works?
  • Create New...