Jump to content

DrQuincy

Members
  • Content Count

    61
  • Joined

  • Last visited

Community Reputation

7 Neutral

About DrQuincy

  • Rank
    Full Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Thanks very much for your example, I'll give it a go tomorrow and let you know. 🙂
  2. I may have missed it in the docs but is there an easy and performant way to count pages that have a date field by year. So, let's say you have a news-item template with a dateFiled field that is of Datetime type. I would like to return something like this: 2020 => 17, 2019 => 46 ... Where the values are year and count respectively. So basically something like this in MySQL by in PW selectors (ideally without having to use raw database queries): SELECT YEAR(`dateFiled`) as `year`, COUNT(YEAR(`dateFiled`)) AS `count` FROM `news` GROUP BY YEAR(`dateFiled`); Thanks!
  3. 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.
  4. 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.
  5. 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!
  6. 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.
  7. 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.
  8. 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. 🙂
  9. 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.
  10. 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. 🙂
  11. 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.
  12. 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?
  13. 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?
  14. 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.
×
×
  • Create New...