Forums / Developer / Webdav upload + unicode = bug ?

Webdav upload + unicode = bug ?

Author Message

Oree Eyo

Tuesday 02 August 2005 11:33:08 pm

Hi All
I wrote this upload handler to insert article and i'm having troubles with unicode.

When I upload a file using the browser using /content/upload everything works fine.the new article is created and the charset is ok. but when I use webdav upload , the unicode characters are lost and I get odd characters instead.
my site is configured to utf-8 and works fine using the browser.
I've tried 3 webdav clients and I get the same result. ( konqueror, DAVexplorer, msie)
<i>
This problem has nothing to do with the file itself since I don't even try to open the file or read it...the unicode text is inside the code..
</i>
I spent 3 days working on this problem and I don't have a clue why this is happening.

eZ crew? Anyone??

function handleFile( &$upload, &$result,
                         $filePath, $originalFilename, $mimeInfo,
                         $location, $existingNode )
    {
    
    $ini =& eZINI::instance( 'i18n.ini' );
    $i18nSettings = array();
    $i18nSettings['internal-charset'] = $ini->variable( 'CharacterSettings', 'Charset' );
    $i18nSettings['http-charset'] = $ini->variable( 'CharacterSettings', 'HTTPCharset' );
    $i18nSettings['mbstring-extension'] = $ini->variable( 'CharacterSettings', 'MBStringExtension' ) == 'enabled';
    eZTextCodec::updateSettings( $i18nSettings );
    $charset = eZTextCodec::internalCharset(); // returns utf-8
    $hcharset = eZTextCodec::httpCharset(); // returns utf-8
  
  //place the new article   
 $tree =  & eZContentObjectTreeNode::fetch(2);       
        $node = $tree->childrenByName(CONTAINER_NODE);
        $nodeID = & $node[0]->MainNodeID;
  
         // we want an article
        $class = eZContentClass::fetchByIdentifier( 'article' );
       
            $creatorID = 14; // 14 == admin
            $parentNodeID = $nodeID;
            $contentObject =& $class->instantiate( $creatorID, 1 );
            $nodeAssignment =& eZNodeAssignment::create( array(
                                                             'contentobject_id' => $contentObject->attribute( 'id' ),
                                                             'contentobject_version' => $contentObject->attribute( 'current_version' ),
                                                             'parent_node' => $parentNodeID,
                                                             'is_main' => 1
                                                             )
                                                         );
            $nodeAssignment->store();

            $version =& $contentObject->version( 1 );
            $version->setAttribute( 'modified', eZDateTime::currentTimeStamp() );
            $version->setAttribute( 'status', EZ_VERSION_STATUS_DRAFT );
            $version->store();

            $contentObjectID = $contentObject->attribute( 'id' );
            $dataMap =& $contentObject->dataMap();
            {
                $titleAttribute = 'title';
                $bodyAttribute = 'body';
                

	//This is a simple xml to store.
            $xmlTextBody = '<?xml version="1.0" encoding="utf-8"?>
<section xmlns:image="http://ez.no/namespaces/ezpublish3/image/"
         xmlns:xhtml="http://ez.no/namespaces/ezpublish3/xhtml/"
         xmlns:custom="http://ez.no/namespaces/ezpublish3/custom/">
  <paragraph>ENTER NON ENGLISH TEXT HERE &#1488;&#1489;&#1490;&#1492;</paragraph>
</section>';
            
                $objectName = $title;

                $dataMap['intro']->setAttribute( 'data_text', 'intro' );
                $dataMap['intro']->store();

                $dataMap[$titleAttribute]->setAttribute( 'data_text', 'test article' );
                $dataMap[$titleAttribute]->store();
                $dataMap[$bodyAttribute]->setAttribute( 'data_text' $xmlTextBody);
                $dataMap[$bodyAttribute]->store();            
        }
            require_once( 'lib/ezutils/classes/ezoperationhandler.php' );
            $operationResult = eZOperationHandler::execute( 'content', 'publish',
                array( 'object_id' => $contentObjectID, 'version' => 1 ) );
    }

Xavier Dutoit

Wednesday 03 August 2005 1:42:02 am

Could you please clarify where you're adding the upload handler and what is you ez version ?

Also, I quite don't get where is the problem: when you're adding the content or when you're trying to see it ?

There is a bug in the webdav (brower part): when it contains accentued chars, it doesn't display them (error message). I sent a patch to ez, don't know if they have fixed it yet. Might be related ?

X+

http://www.sydesy.com

Oree Eyo

Wednesday 03 August 2005 2:25:51 am

xavier.

First. Thanks for the webdav patch. I have it applied and It solved the problem of non-english file (object) names.
Maybe you can tell if it has something to do with my problem. Alltough this is not the browser part of the webdav.

This upload handler is reffered by upload.ini and called by ezp after detecting text/html mime upload this way :
[upload.ini]
MimeUploadHandlerMap[text/html]=myhandler

The idea is to create an article from the uploaded file.
This upload hanlder is called whenever I upload html document no matter if it's via webdav or via http://localhost/corporate_admin/content/upload/
But, as I mentioned above. unicode isn't stored correctly when I upload via webdav.

I think that there's no problem when I upload the content.
I mean. The upload is fine and a new object is created, but when I view it in the admin interface ( and also in the database using phpmyadmin) I see odd characters instead of my unicode text ( again. only if it was a webdav upload).

My ezp Version: 3.7.0rc1 (3.7.0rc1)
SVN revision: 12701

Oree Eyo

Friday 05 August 2005 12:53:16 am

last bump before a bug report...
anyone ?

Xavier Dutoit

Friday 05 August 2005 1:26:48 am

Don't know,

What is the encoding using for the webdav trafic vs. the regular one (have a look at the http headers with something like "live http headers" on firefox) ?

I'd guess that's different encodings, hence the pb, but that's a wild guess.

X+

P.S. If you post a bug report, please remind them about the patch I sent them, it seems to have been forgotten.

http://www.sydesy.com

Oree Eyo

Friday 05 August 2005 2:39:22 am

I'll give it a try but I'm not sure that "Sniffing" http traffic would say something, The problem is somewhere inside the informathion proccess. The following pice of code won't store data as unicode if webdav is calling it, regardless of what you upload.

$utf8text = "NON ENGLISH UNICODE TEXT";
$dataMap[$bodyAttribute]->setAttribute( 'data_text' $utf8text);
$dataMap[$bodyAttribute]->store();      

As you can see, the unicode text is inside the code.

HTTPCharset is set to utf-8 in i18n.ini

 
[CharacterSettings]
Charset=utf-8
HTTPCharset=utf-8
MBStringExtension=enabled

Maybe it doesn't apply to webdav.
I wonder if there's a "WEBDAVCharset=xyz". all tough webdav is on-top http so it should be the same.
gonna do that bug-report later on.

regards.

eZ debug

Timing: Jan 18 2025 11:22:14
Script start
Timing: Jan 18 2025 11:22:14
Module start 'content'
Timing: Jan 18 2025 11:22:14
Module end 'content'
Timing: Jan 18 2025 11:22:15
Script end

Main resources:

Total runtime0.8942 sec
Peak memory usage4,096.0000 KB
Database Queries203

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0088 588.8438180.8359
Module start 'content' 0.00880.7366 769.6797600.4063
Module end 'content' 0.74540.1487 1,370.0859341.3750
Script end 0.8941  1,711.4609 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.4387210.0002
Check MTime0.00160.1794210.0001
Mysql Total
Database connection0.00130.145710.0013
Mysqli_queries0.810790.65722030.0040
Looping result0.00220.24272010.0000
Template Total0.861396.320.4306
Template load0.00250.278520.0012
Template processing0.858896.033220.4294
Template load and register function0.00010.014310.0001
states
state_id_array0.00080.084210.0008
state_identifier_array0.00080.087220.0004
Override
Cache load0.00200.2187540.0000
Sytem overhead
Fetch class attribute can translate value0.00160.182830.0005
Fetch class attribute name0.00140.160770.0002
XML
Image XML parsing0.00080.091530.0003
class_abstraction
Instantiating content class attribute0.00000.002080.0000
General
dbfile0.00240.2654270.0001
String conversion0.00000.000930.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
14content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 36
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs