Adding a PHP expression warning exception in CSS validator - aptana3

I am working with php variables in CSS files. I cannot figure out how to add a warning exception to the CSS validator for <\?php echo $purple; ?>
I tried .*<\?php.*\?> and .*\<\?php.*\?>. But the error keeps poping out at < as Syntax Error: unexpected token "<"

I believe when you add CSS Validator exceptions, you make a regular expression for the error or warning text, not the cause of it. E.g., don't add an exception for .*<\?php.*\?>, add it for Syntax Error: unexpected token "<". See this page for examples: http://morganizeit.com/2008/04/configure-aptana-to-ignore-css-hacks/
It is also worth pointing out that if your regular expression doesn't seem to have an effect on the error/warning you are working on, you may be adding it to the wrong validator as there are often multiple ones at work in any given editor. For example, when I edit CSS, I sometimes get warnings from the CSS Syntax Validator and I sometimes get errors from the W3C Stylesheet Validator. So if your expression is not working in one of those, try it on the other. You can determine an error's source by disabling a validator temporarily and seeing if the warning/error quits.

Related

$quot; not being parsed in laravel email

For some reason, Laravel does not parse " as expected in the footer of emails.
I am expecting to see an actual quote, but it's returning the HTML as-is.
I have tried overriding this using the toMailUsing in my AuthServiceProvider but this particular line doesn't seen to be editable.
Please advise on what I'm doing wrong.

org.thymeleaf.exceptions.TemplateProcessingException: Only variable expressions returning numbers or booleans are allowed in this context

I have been using thymeleaf th:onclick attribute to call javascript function with parameters as below
th:onclick="|myFunction('${parameter1}')|"
But with thymeleaf 3.1.10 this has been removed. and they are suggesting to use th:data attribute.
I however found workaround on as below and both of them are working perfectly.
th:attr="onclick=|myFunction('${parameter1}')|"
th:onclick="#{myFunction('${parameter1}')}">
Now i am not sure if these workarounds are correct way to do things and if yes which one is the better way.
The first will work like you want -- however, you are bypassing the the security restriction and now your pages are vulnerable to javascript injection (which is the original reason this change was made).
The second one just plain doesn't work. It doesn't expand out the variable ${parameter1}, instead just encoding it as a url like this:
onclick="myFunction?$%7Bparameter1%7D"
You really should be doing it as shown on the page.
th:data-parameter1="${parameter1}" onclick="myFunction(this.getAttribute('data-parameter1'));"

Collapsing several "required field missing" errors down to one line in the "stripes:errors" box

I realize this is kind of "Stripes 101", but I guess I skipped that class.
I'd like to use the code that drops the "error" class into the field
tag class strings as the primary way to indicate missing required
fields. I'd then like to show a single error message along with any
other errors (like fields supplied with improper values).
Thus, the error info on the page might look like:
Sorry for the trouble, but:
1. Please supply values for all indicated required fields.
2. Please supply a numeric value for Zip Code.
etc.
I suppose I could go through the validation errors, look for ones for
fields where the value is empty, and make the assumption that those
were the required field errors. However, if I take those errors out
of the set, then I suspect that the page will no longer be able to
mark the erroneously-missing fields with the "error" class.
This seems like something likely to be pretty easy, but I can't find
any specific examples. Maybe I can do it all in the .jsp code; I'll start looking into that.
The DefaultActionBeanPropertyBinder adds an instance of ScopedLocalizableError with the default scope value of "validation.required" when a required field is missing.
So you coult probably write a tag similar to the stripes errors tag, but which collapes all the instances of ScopedLocalizableError having a default scope of "validation.required" to a single error message.

ValidateRegExp client-side vs server-side issue

I'm using monorail, activerecord, and jquery. I have a form with a zip code textbox. I have in my active record class associated to the form:
[Property]
[ValidateNonEmpty]
[ValidateRegExp(#"/^\d{5}(-\d{4})?$/", "Invalid")]
public string ZipCode { get; set; }
As you can see, I'm using the ValidateRegExp attribute, which then auto-generates jQuery validate rules. The issue is that regular expressions are different in javascript than they are in C#. Javascript requires a / before and after the regex, whereas C# does not. If I put the slashes then the jQuery validation will work, but if they bypass the javascript validation and submit the form with js disabled (or if someone saves the object through another means like a test case) then it'll say the zip code is invalid because C# doesn't like the slashes.
So my question is, how do you please both javascript and C# with one regex? I would expect it to be smart enough to add slashes before and after just for the jQuery validation so that you could specify the regex in C# without the slashes but this is not the case it seems.
You should be specifying the regular expression itself, without the surrounding / characters.
If you are having problems with the client side, it would help if you'd include the JS error you see (if any), and actual generated JS code on the page that is being written out by Monorail to your page, and also the version of Monorail you are using.
As a side note, lets look at the code generating the JS validation rule from the validation attribute in JQueryValidator.cs
the relevant piece is at line 378 (as of current version of the codebase):
"function(value, element, param) { return new RegExp(param).test(value); }"
which points to the fact that the new RegExp(expression) is used, rather than the /expression/ format.
With that - it is clear that Monorail's jquery validator integration is ok.
I'm using jQuery 1.4.2. Not sure what version of MonoRail I'm using, the Castle.MonoRail.Framework dll says v2.0.0.0. I updated it within the last 3 months though so it's fairly new. The js that you're showing indicates that you have an even newer version than me, as it generates the following for me (if no slashes included in the ValidateRegExp expression):
"user.username":{ required: true , regExp: ^[\w ]{4,50}$ }
This obviously gives a syntax error in js, as it's not wrapped in quotes or slashes. I ended up creating a new RegExp validator with AbstractValidator as the base class to get around the faulty one that is in my version of MonoRail.
Do you know if this was an issue that was fixed in the last couple of months? Otherwise I can't explain how yours generates new RegExp in js and mine does not...

How to get rid of this w3 validation error?

I developed a web page and now i am validating it with w3c HTML4.0... I got one error it says
Error Line 30, Column 57: there is no attribute "DATA-FLEXMENU"
href="about.php" class="mainlink" data-flexmenu="flexmenu1">About Us</a></div>
You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead).
Any ways of getting rid of this error .... Any suggestion...
data attributes are present in HTML5.
see HTML 5 data- Attributes
Either you can change the doctype to html5 or remove the data attribute.
You can specify HTML 5 doctype like
<!DOCTYPE html>
As unhelpful as it will sound, either remove the attribute "data-flexmenu" from your markup, or accept a non-valid result.
The results are accurate, the A element in the DTD does not contain an attribute definition for the attribute data-flexmenu.
Alternatively you could define your own DTD and host it on a central server and reference that instead of the w3c one.
Or (as pointed out) use HTML5 DTD not HTML 4 DTD

Resources