On 04/07/2010 03:15 PM, lucaa (SVN) wrote:
> Author: lucaa
> Date: 2010-04-07 15:15:44 +0200 (Wed, 07 Apr 2010)
> New Revision: 28168
>
> Modified:
>     
> platform/xwiki-applications/trunk/annotations/src/main/resources/AnnotationCode/CreateForm.xml
>     
> platform/xwiki-applications/trunk/annotations/src/main/resources/AnnotationCode/Macros.xml
>     
> platform/xwiki-applications/trunk/annotations/src/main/resources/AnnotationCode/Script.xml
> Log:
> XAANNOTATIONS-13: URL Decode annotation target before using it in 
> AnnotationService
> * Fixed encoding across all annotations js and velocity scripts
>
>
> Modified: 
> platform/xwiki-applications/trunk/annotations/src/main/resources/AnnotationCode/CreateForm.xml
> ===================================================================
> --- 
> platform/xwiki-applications/trunk/annotations/src/main/resources/AnnotationCode/CreateForm.xml
>     2010-04-07 08:56:02 UTC (rev 28167)
> +++ 
> platform/xwiki-applications/trunk/annotations/src/main/resources/AnnotationCode/CreateForm.xml
>     2010-04-07 13:15:44 UTC (rev 28168)
> @@ -12,8 +12,8 @@
>   <customClass></customClass>
>   <contentAuthor>XWiki.Admin</contentAuthor>
>   <creationDate>1265236156000</creationDate>
> -<date>1266926719000</date>
> -<contentUpdateDate>1266926719000</contentUpdateDate>
> +<date>1270643626000</date>
> +<contentUpdateDate>1270643626000</contentUpdateDate>
>   <version>1.1</version>
>   <title></title>
>   <template></template>
> @@ -37,9 +37,9 @@
>   {{html}}
>   ## get create a hashmap with request data about the selection
>   #set($annData = $util.hashMap)
> -#set($dispose = $annData.put("selection", 
> $util.decodeURI($!request.selection)))
> -#set($dispose = $annData.put("selectionContext", 
> $util.decodeURI($!request.selectionContext)))
> -#set($dispose = $annData.put("selectionOffset", 
> $util.decodeURI($!request.selectionOffset)))
> +#set($dispose = $annData.put("selection", $!request.selection))
> +#set($dispose = $annData.put("selectionContext", $!request.selectionContext))
> +#set($dispose = $annData.put("selectionOffset", $!request.selectionOffset))
>   ## pretend that annotation author is current user, and annotation date is 
> now
>   ##Even if they get sent to the server, the server will overwrite with 
> anything's logged in in there anyway
>   #set($dispose = $annData.put("author", $context.user))
>
> Modified: 
> platform/xwiki-applications/trunk/annotations/src/main/resources/AnnotationCode/Macros.xml
> ===================================================================
> --- 
> platform/xwiki-applications/trunk/annotations/src/main/resources/AnnotationCode/Macros.xml
>         2010-04-07 08:56:02 UTC (rev 28167)
> +++ 
> platform/xwiki-applications/trunk/annotations/src/main/resources/AnnotationCode/Macros.xml
>         2010-04-07 13:15:44 UTC (rev 28168)
> @@ -12,8 +12,8 @@
>   <customClass></customClass>
>   <contentAuthor>XWiki.Admin</contentAuthor>
>   <creationDate>1264959390000</creationDate>
> -<date>1267569743000</date>
> -<contentUpdateDate>1267569743000</contentUpdateDate>
> +<date>1270643964000</date>
> +<contentUpdateDate>1270643964000</contentUpdateDate>
>   <version>1.1</version>
>   <title></title>
>   <template></template>
> @@ -47,7 +47,7 @@
>    *#
>   #macro(displayCreateBox $docWiki $docSpace $docPage $annData)
>   &lt;div class="annotation-box annotation-box-create"&gt;
> -&lt;form method="POST" 
> action="/xwiki/rest/wikis/${docWiki}/spaces/${docSpace}/pages/${docPage}/annotations?media=json"&gt;
> +&lt;form method="POST" 
> action="/xwiki/rest/wikis/${util.encodeURI($docWiki)}/spaces/${util.encodeURI($docSpace)}/pages/${util.encodeURI($docPage)}/annotations?media=json"&gt;
>       &lt;div class="hidden"&gt;
>         #foreach($field in $annData.keySet())
>            &lt;input type="hidden" name="${field}" 
> value="$!{annData.get(${field})}"/&gt;
> @@ -73,7 +73,7 @@
>     &lt;div class="annotation-box annotation-box-edit"&gt;
>       #if($ann)
>         ## TODO: fix this url to be generated less hardcoded
> -      #set($editURL = "/xwiki/rest/wikis/" + $docWiki + "/spaces/" + 
> $docSpace + "/pages/" + $docPage + "/annotation/" + $util.encodeURI($ann.id) 
> + "?method=PUT&amp;media=json")
> +      #set($editURL = "/xwiki/rest/wikis/" + $$util.encodeURI($docWiki) + 
> "/spaces/" + $util.encodeURI($docSpace) + "/pages/" + 
> $util.encodeURI($docPage) + "/annotation/" + $util.encodeURI($ann.id) + 
> "?method=PUT&amp;media=json")
>         &lt;form method='POST' action="${editURL}"&gt;
>           #displayAnnotation($ann, 'edit')
>           #displayAnnotationBoxButtons('edit')
> @@ -174,7 +174,7 @@
>   #macro(displayAnnotationToolbox $ann $mode $docWiki $docSpace $docPage)
>     &lt;span class="annotationTools"&gt;
>       #if($mode != 'create'&amp;&amp; $annotations.canEditAnnotation($ann.id, 
> $docWiki, $docSpace, $docPage))
> -      #set($editURL = "/xwiki/rest/wikis/" + $docWiki + "/spaces/" + 
> $docSpace + "/pages/" + $docPage + "/annotation/" + $util.encodeURI($ann.id) 
> + "?method=PUT&amp;media=json")

Instead of $util.encodeURI you should use $escapetool.url

> +      #set($editURL = "/xwiki/rest/wikis/" + $util.encodeURI($docWiki) + 
> "/spaces/" + $util.encodeURI($docSpace) + "/pages/" + 
> $util.encodeURI($docPage) + "/annotation/" + $util.encodeURI($ann.id) + 
> "?method=PUT&amp;media=json")
>         #if ("$!{ann.state}" == 'UPDATED')
>           &lt;span class="tool accept"&gt;&lt;a class="validate" 
> href="${editURL}" 
> title="$msg.get('annotations.action.validate.tooltip')"&gt;$msg.get('annotations.action.validate.text')&lt;/a&gt;&lt;/span&gt;
>         #end
> @@ -183,7 +183,7 @@
>           &lt;span class="tool annotationEdit"&gt;&lt;a class="edit" 
> href="${editURL}" 
> title="$msg.get('annotations.action.edit.tooltip')"&gt;$msg.get('annotations.action.edit.text')&lt;/a&gt;&lt;/span&gt;
>         #end
>         ## TODO: fix this url to be generated less hardcoded
> -      #set($deleteURL = "/xwiki/rest/wikis/" + $docWiki + "/spaces/" + 
> $docSpace + "/pages/" + $docPage + "/annotation/" + $util.encodeURI($ann.id) 
> + "?method=DELETE&amp;media=json")
> +      #set($deleteURL = "/xwiki/rest/wikis/" + $util.encodeURI($docWiki) + 
> "/spaces/" + $util.encodeURI($docSpace) + "/pages/" + 
> $util.encodeURI($docPage) + "/annotation/" + $util.encodeURI($ann.id) + 
> "?method=DELETE&amp;media=json")
>         &lt;span class="tool delete"&gt;&lt;a class="delete" 
> href="${deleteURL}" 
> title="$msg.get('annotations.action.delete.tooltip')"&gt;$msg.get('annotations.action.delete.text')&lt;/a&gt;&lt;/span&gt;
>       #end
>     &lt;/span&gt;
>
> Modified: 
> platform/xwiki-applications/trunk/annotations/src/main/resources/AnnotationCode/Script.xml
> ===================================================================
> --- 
> platform/xwiki-applications/trunk/annotations/src/main/resources/AnnotationCode/Script.xml
>         2010-04-07 08:56:02 UTC (rev 28167)
> +++ 
> platform/xwiki-applications/trunk/annotations/src/main/resources/AnnotationCode/Script.xml
>         2010-04-07 13:15:44 UTC (rev 28168)
> @@ -12,8 +12,8 @@
>   <customClass></customClass>
>   <contentAuthor>XWiki.Admin</contentAuthor>
>   <creationDate>1264860755000</creationDate>
> -<date>1270590698000</date>
> -<contentUpdateDate>1270590698000</contentUpdateDate>
> +<date>1270643534000</date>
> +<contentUpdateDate>1270643534000</contentUpdateDate>
>   <version>1.1</version>
>   <title></title>
>   <template></template>
> @@ -847,7 +847,7 @@
>
>     fetchAnnotations : function(andShow) {
>       // TODO: fixme, get the URL in a less hardcoded way
> -    var getAnnotationsURL = '/xwiki/rest/wikis/' + XWiki.currentWiki + 
> '/spaces/' + XWiki.currentSpace + '/pages/' + 
> $$('meta[name=page]')[0].content + '/annotations?media=json';
> +    var getAnnotationsURL = '/xwiki/rest/wikis/' + 
> encodeURIComponent(XWiki.currentWiki) + '/spaces/' + 
> encodeURIComponent(XWiki.currentSpace) + '/pages/' + 
> encodeURIComponent($$('meta[name=page]')[0].content) + 
> '/annotations?media=json';
>       new Ajax.Request(getAnnotationsURL, {method: 'GET',
>         parameters: this.prepareRequestParameters(new Hash()),
>         onCreate: function() {
> @@ -1037,9 +1037,9 @@
>           new Ajax.Request('$xwiki.getURL("AnnotationCode.EditForm")', {
>             parameters: {
>               'xpage' : 'plain',
> -            'wiki' : encodeURIComponent(XWiki.currentWiki),
> -            'space' : encodeURIComponent(XWiki.currentSpace),
> -            'page' : encodeURIComponent($$('meta[name=page]')[0].content),
> +            'wiki' : XWiki.currentWiki,
> +            'space' : XWiki.currentSpace,

$$ is really slow in IE, you should use something faster, like setting 
XWiki.currentDocumentName to this value first.

> +            'page' : $$('meta[name=page]')[0].content,
>               'id' : id
>             },
>             onCreate : function() {
> @@ -1124,9 +1124,9 @@
>         parameters: {
>           'id' : annotationId,
>           'xpage' : 'plain',
> -        'wiki' : encodeURIComponent(XWiki.currentWiki),
> -        'space' : encodeURIComponent(XWiki.currentSpace),
> -        'page' : encodeURIComponent($$('meta[name=page]')[0].content)
> +        'wiki' : XWiki.currentWiki,
> +        'space' : XWiki.currentSpace,
> +        'page' : $$('meta[name=page]')[0].content
>         },
>         onSuccess: function(response) {
>           // display the annotation creation form


-- 
Sergiu Dumitriu
http://purl.org/net/sergiu/
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to