Hello,

I'm a bit confused when it comes to abstract string classes, i.e. nsAString. 
The Mozilla internal string guide speaks of them as "historic", so I wondered 
that they are still expected as input value in nsDOMTokenList::Contains

In nsScriptLoader::ProcessScriptElement I want to do the following:

  nsCOMPtr<nsIContentSecurityPolicy> csp;

  nsAString& str1 = NS_LITERAL_STRING("string1");
  nsAString& str2 = csp->getMyStringValue();

  str1.Append(str2);

  // call Contains(str1) now, to check if the string "string1string2"
  // is a value of an element attribut

Explanation:

  - getMyStringValue() is supposed to be a JavaScript function written
    in contentSecurityPolicy.js and delivers a value from CSPRep, very
    smililar to what getAllowsEval does with _allowEval. The returned value
    is always a mixed string consisting of upper and lower case letters and
    numbers, e.g. "Abc123"

  - after the Append operation str1 should contain "string1string2"

Question 1: My above handling of this issue seems to be erroneous. How do I
            use the strings correctly inside this context?

Question 2: nsDOMTokenList defines Contains(const nsAString& aToken,
            ErrorResult& aError). However, I found this function nowhere used
            in this way. Can I simply call it via Contains(str1) as it is
            done in lines 111 or 148?

Thanks for your support.
Jeremy
  
  

_______________________________________________
dev-security mailing list
dev-security@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-security

Reply via email to