CRM_Contact_Form_Edit_Address::setDefaultValues( $defaults, $this );
if (CRM_Utils_Array::value('image_URL', $defaults)) {
- list($imageWidth, $imageHeight) = getimagesize($defaults['image_URL']);
+ list($imageWidth, $imageHeight) = getimagesize(CRM_Utils_String::unstupifyUrl($defaults['image_URL']));
list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
$this->assign('imageWidth', $imageWidth);
$this->assign('imageHeight', $imageHeight);
$image_URL = str_replace('http://', 'https://', $image_URL);
}
- list($imageWidth, $imageHeight) = getimagesize($image_URL);
+ list($imageWidth, $imageHeight) = getimagesize(CRM_Utils_String::unstupifyUrl($image_URL));
list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
$this->assign("imageWidth", $imageWidth);
$this->assign("imageHeight", $imageHeight);
}
}
elseif ($name == 'image_URL') {
- list($width, $height) = getimagesize($details->$name);
+ list($width, $height) = getimagesize(CRM_Utils_String::unstupifyUrl($details->$name));
list($thumbWidth, $thumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($width, $height);
$image_URL = '<img src="' . $details->$name . '" height= ' . $thumbHeight . ' width= ' . $thumbWidth . ' />';
}
if (CRM_Utils_Array::value('image_URL', $this->_defaults)) {
- list($imageWidth, $imageHeight) = getimagesize($this->_defaults['image_URL']);
+ list($imageWidth, $imageHeight) = getimagesize(CRM_Utils_String::unstupifyUrl($this->_defaults['image_URL']));
list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
$this->assign("imageWidth", $imageWidth);
$this->assign("imageHeight", $imageHeight);
}
}
-
+ /**
+ * Many parts of the codebase have a convention of internally passing around
+ * HTML-encoded URLs. This effectively means that "&" is replaced by "&"
+ * (because most other odd characters are %-escaped in URLs; and %-escaped
+ * strings don't need any extra escaping in HTML).
+ *
+ * @param string $url URL with HTML entities
+ * @return string URL without HTML entities
+ */
+ public static function unstupifyUrl($htmlUrl) {
+ return str_replace('&', '&', $htmlUrl);
+ }
}