]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-19756 Try to bring some consistency to how we handle & is attribute values.
authortjhunt <tjhunt>
Wed, 29 Jul 2009 08:52:49 +0000 (08:52 +0000)
committertjhunt <tjhunt>
Wed, 29 Jul 2009 08:52:49 +0000 (08:52 +0000)
lib/outputlib.php
lib/weblib.php

index 25c9f7b4a2253524869acc4baf9a6d11e74a5669..724af1b1d05eb29b9e365d8a0b114bba31cebc6b 100644 (file)
@@ -1314,7 +1314,7 @@ class moodle_renderer_base {
     /**
      * Outputs a HTML attribute and value
      * @param string $name The name of the attribute ('src', 'href', 'class' etc.)
-     * @param string $value The value of the attribute
+     * @param string $value The value of the attribute. The value will be escaped with {@link s()}
      * @return string HTML fragment
      */
     protected function output_attribute($name, $value) {
@@ -1322,13 +1322,14 @@ class moodle_renderer_base {
         if ($value == HTML_ATTR_EMPTY) {
             return ' ' . $name . '=""';
         } else if ($value || is_numeric($value)) { // We want 0 to be output.
-            return ' ' . $name . '="' . $value . '"';
+            return ' ' . $name . '="' . s($value) . '"';
         }
     }
 
     /**
      * Outputs a list of HTML attributes and values
      * @param array $attributes The tag attributes (array('src' => $url, 'class' => 'class1') etc.)
+     *       The values will be escaped with {@link s()}
      * @return string HTML fragment
      */
     protected function output_attributes($attributes) {
index 23ce3ba2ec2eb266992e4809ef1e070745f2f351..5560cfe6eb7d672210964e86bee9ec18e37750e5 100644 (file)
@@ -489,7 +489,7 @@ class moodle_url {
  *
  * @param mixed $url The URL (moodle_url or string)
  * @param bool $stripformparams Whether or not to strip the query params from the URL
- * @return string
+ * @return string the URL. &s are unescaped. You must use s(...) to output this to XHTML. ($OUTPUT normally does this automatically.)
  */
 function prepare_url($url, $stripformparams=false) {
     global $CFG, $PAGE;
@@ -497,7 +497,7 @@ function prepare_url($url, $stripformparams=false) {
     $output = $url;
 
     if ($url instanceof moodle_url) {
-        $output = $url->out($stripformparams);
+        $output = $url->out($stripformparams, array(), false);
     }
 
     // Handle relative URLs