OSDN Git Service

fix javascript in wiki output.
authorvisor <visor@users.sourceforge.jp>
Fri, 13 Jan 2012 13:59:39 +0000 (22:59 +0900)
committervisor <visor@users.sourceforge.jp>
Fri, 13 Jan 2012 13:59:39 +0000 (22:59 +0900)
wiki/wikiattrib.cc
wiki/wikiattrib.h
wiki/wikiformat.cc
wiki/wikiformat.h
wiki/wikiline.cc

index 0aee5c9..eebaced 100644 (file)
@@ -10,7 +10,6 @@ bool  WikiAttrib1::readAttrib1 (WikiMotorObjVec* cell, bool& rc) {
     bool  ferr = false;
 
     if (cell->size () == 0) {
-//     if (fwhole)
        if (mode == M_ATTRIB || mode == M_ATTRIB_TEXT)
            return true;
        else
@@ -43,7 +42,6 @@ bool  WikiAttrib1::readAttrib1 (WikiMotorObjVec* cell, bool& rc) {
            wiki->paramTargetBody (key, vval.textOut (wiki), target, ferr);
        } else if (readAttribMore (key, vval, ferr)) {
        } else {
-//         if (fwhole) {
            if (mode == M_ATTRIB) {
                wiki->errorMsg.append (cell->dump ()).append (CharConst (": bad attribute.\n"));
                rc = false;
@@ -63,7 +61,6 @@ bool  WikiAttrib1::readAttrib1 (WikiMotorObjVec* cell, bool& rc) {
        } else if ((selector & SEL_SCRIPT2) && checkScript (*cell, script, ferr)) {
        } else if (readAttribMore2 (key, *cell, ferr)) {
        } else {
-//         if (fwhole) {
            if (mode == M_ATTRIB) {
                wiki->errorMsg.append (cell->dump ()).append (CharConst (": bad attribute.\n"));
                rc = false;
@@ -87,7 +84,6 @@ bool  WikiAttrib1::shiftAttrib (WikiMotorObjVecPtr& vec) {
        WikiMotorObjVec  cell;
 
        v2 = WikiMotorObjVecPtr (new WikiMotorObjVec);
-//     if (vec->splitChar (':', cell, *v2) || fwhole) {
        if (vec->splitChar (':', cell, *v2) || mode == M_ATTRIB || mode == M_ATTRIB_TEXT) {
            if (! readAttrib1 (&cell, rc))
                return rc;
@@ -236,12 +232,11 @@ bool  WikiAttrib1::shiftName (WikiMotorObjVecPtr& vec, ustring& name) {
 void  WikiAttrib1::output (MotorOutput* out) {
     wiki->outputID (out, id);
     wiki->outputClass (out, classlist);
-    wiki->outputSubmitScript (out, CharConst ("onclick"), onclick);
-    wiki->outputSubmitScript (out, CharConst ("onfocus"), onfocus);
-    wiki->outputSubmitScript (out, CharConst ("onblur"), onblur);
-    wiki->outputSubmitScript (out, CharConst ("onchange"), onchange);
+    wiki->outputSubmitScript (out, CharConst ("onclick"), onclick, scriptcut);
+    wiki->outputSubmitScript (out, CharConst ("onfocus"), onfocus, scriptcut);
+    wiki->outputSubmitScript (out, CharConst ("onblur"), onblur, scriptcut);
+    wiki->outputSubmitScript (out, CharConst ("onchange"), onchange, scriptcut);
     wiki->outputName (out, CharConst ("target"), target);
-//    wiki->outputName (out, CharConst ("size"), elsize);
     wiki->outputFlag (out, CharConst ("multiple"), fmultiple);
     // no fdefault
     outputMore (out);
@@ -528,15 +523,12 @@ bool  WikiAttribButton::readAttrib (WikiMotorObjVecVec::const_iterator& b, const
 
     if (b < e) {
        WikiMotorObjVec*  cell = b->get ();
-//     bool  bf = fwhole;
-//     fwhole = false;
        mode_t  bm = mode;
 
        mode = M_NORMAL;
        if (! readAttrib1 (cell, rc)) {
            name = cell->textOut (wiki);
        }
-//     fwhole = bf;
        mode = bm;
        b ++;
     }
index 5491888..2898f23 100644 (file)
@@ -26,7 +26,6 @@ class  WikiAttrib1 {
     }  mode_t;
 
     uint32_t  selector;
-//    bool  fwhole;
     mode_t  mode;
     WikiFormat*  wiki;
     bool  ferr;
@@ -36,19 +35,17 @@ class  WikiAttrib1 {
     ustring  onfocus;
     ustring  onblur;
     ustring  onchange;
+    bool  scriptcut;
     ustring  target;
-//    int32_t  elsize;
     bool  fmultiple;
     bool  fdefault;            /* no output */
     ustring  script;           /* no output */
     
-//    WikiAttrib1 (WikiFormat* _wiki, uint32_t _selector, bool _fwhole = false) {
-    WikiAttrib1 (WikiFormat* _wiki, uint32_t _selector, mode_t _mode = M_NORMAL) {
+    WikiAttrib1 (WikiFormat* _wiki, uint32_t _selector, bool _scriptcut, mode_t _mode = M_NORMAL) {
        wiki = _wiki;
        selector = _selector;
-//     fwhole = _fwhole;
        mode = _mode;
-//     elsize = 0;
+       scriptcut = _scriptcut;
        fdefault = false;
        fmultiple = false;
     };
@@ -104,12 +101,10 @@ class  WikiAttribTable: public WikiAttrib1 {
     int  cellspacing;
     int  cellpadding;
     bool  fpadding;
-//    halign_t  halign;
     bool  fnowhite;
     bool  fturn;
 
-//    WikiAttribTable (WikiFormat* _wiki, selector_t _selector2, bool _inheader): WikiAttrib1 (_wiki, SEL_ID, _inheader) {
-    WikiAttribTable (WikiFormat* _wiki, selector_t _selector2, mode_t _mode): WikiAttrib1 (_wiki, SEL_ID, _mode) {
+    WikiAttribTable (WikiFormat* _wiki, selector_t _selector2, mode_t _mode): WikiAttrib1 (_wiki, SEL_ID, false, _mode) {
        selector2 = _selector2;
        init ();
     };
@@ -128,8 +123,7 @@ class  WikiAttribImg: public WikiAttrib1 {
     ustring  height;
     ustring  alt;
 
-//    WikiAttribImg (WikiFormat* _wiki): WikiAttrib1 (_wiki, SEL_ID, true) {};
-    WikiAttribImg (WikiFormat* _wiki): WikiAttrib1 (_wiki, SEL_ID, M_ATTRIB) {};
+    WikiAttribImg (WikiFormat* _wiki): WikiAttrib1 (_wiki, SEL_ID, false, M_ATTRIB) {};
     virtual  ~WikiAttribImg () {};
  private:
     virtual bool  readAttribMore (const ustring& key, WikiMotorObjVec& vval, bool& ferr);
@@ -156,7 +150,7 @@ class  WikiAttribInput: public WikiAttrib1 {
     }  pwrap;
     bool  ftab;
 
-    WikiAttribInput (WikiFormat* _wiki, uint32_t _sel2): WikiAttrib1 (_wiki, SEL_MULTIPLE2, M_ATTRIB) {
+    WikiAttribInput (WikiFormat* _wiki, uint32_t _sel2): WikiAttrib1 (_wiki, SEL_MULTIPLE2, false, M_ATTRIB) {
        selector2 = _sel2;
        elsize = 0;
        pdefault = false;
@@ -175,8 +169,7 @@ class  WikiAttribButton: public WikiAttrib1 {
  public:
     ustring  name;
 
-//    WikiAttribButton (WikiFormat* _wiki): WikiAttrib1 (_wiki, SEL_SCRIPT2, true) {};
-    WikiAttribButton (WikiFormat* _wiki): WikiAttrib1 (_wiki, SEL_SCRIPT2, M_ATTRIB) {};
+    WikiAttribButton (WikiFormat* _wiki, bool _scriptcut): WikiAttrib1 (_wiki, SEL_SCRIPT2, _scriptcut, M_ATTRIB) {};
     virtual  ~WikiAttribButton () {};
     virtual bool  readAttrib (WikiMotorObjVecVec::const_iterator& b, const WikiMotorObjVecVec::const_iterator& e);
 };
index 1983bd0..7a4113e 100644 (file)
@@ -377,7 +377,7 @@ bool  WikiBlockH::checkEmpty () {
 インライン要素の解釈は行われない。
 
 */
-bool  WikiBlockPreformat::nextLine (uiterator b, uiterator e) {
+bool  WikiBlockPreformatRaw::nextLine (uiterator b, uiterator e) {
     if (*b == markup) {
        addLine (b, e);
        return true;
@@ -386,7 +386,7 @@ bool  WikiBlockPreformat::nextLine (uiterator b, uiterator e) {
     }
 }
 
-void  WikiBlockPreformat::addLine (uiterator b, uiterator e) {
+void  WikiBlockPreformatRaw::addLine (uiterator b, uiterator e) {
     markup = *b;
 #ifdef WIKIMOTORPRE
     if (markup == ' ') {
@@ -405,7 +405,7 @@ void  WikiBlockPreformat::addLine (uiterator b, uiterator e) {
 #endif
 }
 
-void  WikiBlockPreformat::output (MotorOutput* out) {
+void  WikiBlockPreformatRaw::output (MotorOutput* out) {
 #ifdef WIKIMOTORPRE
     out->out_raw (CharConst ("<pre>"))->out_toText (text)->out_raw (CharConst ("</pre>\n"));
 #else
@@ -601,17 +601,11 @@ bool  WikiBlockItemDL::nextLine (uiterator b, uiterator e) {
 }
 
 void  WikiBlockItemDL::addLine (uiterator b, uiterator e) {
-//    WikiMotor  motor (b + 1, e, wiki);
     WikiMotorObjVec  objs;
-//    ustring  def, desc;
     WikiMotorObjVec*  def;
     WikiMotorObjVec*  desc;
 
-//    motor.compile (objs);
     wiki->wikiMotorInline (b + 1, e, objs);
-//    objs.splitChar (wiki, ':', def, desc);
-//    html1.push_back (def);
-//    html2.push_back (desc);
     def = new WikiMotorObjVec;
     desc = new WikiMotorObjVec;
     objv1.push_back (def);
@@ -623,9 +617,6 @@ void  WikiBlockItemDL::output (MotorOutput* out) {
     int  i;
 
     out->out_raw (CharConst ("<dl>\n"));
-//    for (i = 0; i < html1.size (); i ++) {
-//     out->out_raw (CharConst ("<dt>"))->out_toText (html1[i])->out_raw (CharConst ("</dt>\n"));
-//     out->out_raw (CharConst ("<dd>"))->out_toText (html2[i])->out_raw (CharConst ("</dd>\n"));
     for (i = 0; i < objv1.size (); i ++) {
        out->out_raw (CharConst ("<dt>"))->out_toText (objv1[i].htmlOut (wiki))->out_raw (CharConst ("</dt>\n"));
        out->out_raw (CharConst ("<dd>"))->out_toText (objv2[i].htmlOut (wiki))->out_raw (CharConst ("</dd>\n"));
@@ -662,6 +653,8 @@ void  WikiBlockItemDL::output (MotorOutput* out) {
 |onclick=''fn(arg1,arg2,...)''||onClick属性を出力する。''name''はdefun-wiki-linkで定義したもの。|
 |nowhite|nw||
 |turn||セルの並びの横方向と縦方向を交換する。|
+|toptitle|tt|class=toptitleと同じ。|
+|bottomtitle|bt|class=bottomtitleと同じ。|
 
 +・行オプション
  |row:bgcolor=#ff0|&[;&[;Name]]|&[;&[;Value]]|
@@ -866,14 +859,12 @@ void  WikiBlockTable::addLine_head (uiterator b, uiterator e) {
        objvv.pop_back ();
     attrib.shiftAttrib (objvv[0]);
 
-//    cell = new TableCell (wiki, false);
     cell = new TableCell (wiki, WikiAttrib1::M_NORMAL);
     cell->cellBody (objvv[0].get (), this, 0);
     captionHtml = cell->html;
     delete cell;
 
     for (i = 1; i < objvv.size (); i ++) {
-//     cell = new TableCell (wiki, true);
        cell = new TableCell (wiki, WikiAttrib1::M_ATTRIB);
        cell->cellattrib.shiftAttrib (objvv[i]);
        defaultList.push_back (cell);
@@ -894,7 +885,6 @@ void  WikiBlockTable::addLine_body (uiterator b, uiterator e) {
        cont = false;
        cols = &ary.back ();
     } else {
-//     cols = new CellList_t;
        cols = new CellList_t (wiki);
        ary.push_back (cols);
     }
@@ -974,7 +964,6 @@ void  WikiBlockTable::addLine_body (uiterator b, uiterator e) {
 }
 
 WikiBlockTable::TableCell*  WikiBlockTable::newCell (int idx) {
-//    TableCell*  ans = new TableCell (wiki, false);
     TableCell*  ans = new TableCell (wiki, WikiAttrib1::M_NORMAL);
 
     if (idx < defaultList.size ())
@@ -983,7 +972,6 @@ WikiBlockTable::TableCell*  WikiBlockTable::newCell (int idx) {
 }
 
 WikiBlockTable::TableCell*  WikiBlockTable::newCell (WikiAttribTable& rowattrib) {
-//    TableCell*  ans = new TableCell (wiki, false);
     TableCell*  ans = new TableCell (wiki, WikiAttrib1::M_NORMAL);
 
     ans->cellattrib.copyFrom (rowattrib);
@@ -1400,7 +1388,7 @@ void  WikiBlockForm::output (MotorOutput* out) {
     }
     if (fscript) {
        wiki->outputName (out, CharConst ("action"), ustring (CharConst ("#")), false);
-       wiki->outputSubmitScript (out, CharConst ("onsubmit"), url);
+       wiki->outputSubmitScript (out, CharConst ("onsubmit"), url, true);
     } else {
        wiki->outputName (out, CharConst ("action"), url, false);
     }
@@ -1702,7 +1690,7 @@ void  WikiFormat::compileLine (WikiLineScanner& scanner) {
                   || b[0] == kWikiPRE2) {      // TAB
            if (cur)
                cur->close ();
-           cur = new WikiBlockPreformat (this);
+           cur = new WikiBlockPreformatRaw (this);
            blockp->push_back (cur);
            cur->addLine (b, e);
        } else if (b[0] == kWikiUL) {   // *
@@ -2026,14 +2014,17 @@ void  WikiFormat::outputClass (MotorOutput* out, std::vector<ustring>& classes)
     }
 }
 
-void  WikiFormat::outputSubmitScript (MotorOutput* out, const char* name, size_t len, const ustring& onclick) {
-    if (onclick.length () > 0)
+void  WikiFormat::outputSubmitScript (MotorOutput* out, const char* name, size_t len, const ustring& onclick, bool scriptcut) {
+    if (onclick.length () > 0) {
        out->out_raw (uSPC)
            ->out_raw (name, len)
            ->out_raw (CharConst ("=\""))
-           ->out_toHTML_noCtrl (onclick)
-           ->out_raw ("return false;\"");
-//         ->out_raw ("\"");
+           ->out_toHTML_noCtrl (onclick);
+       if (scriptcut)
+           out->out_raw (CharConst ("return false;\""));
+       else
+           out->out_raw (CharConst ("\""));
+    }
 }
 
 void  WikiFormat::wikiMotor (uiterator b, uiterator e, WikiMotorObjVec& ans) {
@@ -2080,20 +2071,6 @@ MNode*  WikiFormat::buildArgs (WikiMotorObjVecVec::const_iterator b, WikiMotorOb
     }
     
     return ans.release ();
-#if 0
-    MNode*  ans = NULL;
-    MNode*  a;
-
-    if (b < e) {
-       ans = a = new MNode;
-       a->set_car (newMNode_str (new ustring ((*b)->textOut (this))));
-       for (b ++; b < e; b ++) {
-           newMNodeCdr (a);
-           a->set_car (newMNode_str (new ustring ((*b)->textOut (this))));
-       }
-    }
-    return ans;
-#endif
 }
 
 void  WikiFormat::logLispFunctionError (const ustring& msg, const ustring& cmd) {
index 194153c..0c53bb9 100644 (file)
@@ -142,7 +142,7 @@ class  WikiBlock {
        BlockNone,
        BlockParagraph,
        BlockH,
-       BlockPreformat,
+       BlockPreformatRaw,
        BlockItemText,
        BlockItemUL,
        BlockItemOL,
@@ -201,7 +201,6 @@ class  WikiBlockParagraph: public WikiBlock {
     int  count;
     bool  singleTag;
     bool  pflag;
-//    ustring  html;
     WikiMotorObjVec  objv;
 
     WikiBlockParagraph (WikiFormat* w): WikiBlock (BlockParagraph, w) {
@@ -243,15 +242,15 @@ class  WikiBlockH: public WikiBlockComplex {
     virtual bool  checkEmpty ();
 };
 
-class  WikiBlockPreformat: public WikiBlock {
+class  WikiBlockPreformatRaw: public WikiBlock {
  public:
     ustring  text;
     char  markup;
 
-    WikiBlockPreformat (WikiFormat* w): WikiBlock (BlockPreformat, w) {
+    WikiBlockPreformatRaw (WikiFormat* w): WikiBlock (BlockPreformatRaw, w) {
        markup = 0;
     };
-    virtual  ~WikiBlockPreformat () {};
+    virtual  ~WikiBlockPreformatRaw () {};
 
     virtual bool  nextLine (uiterator b, uiterator e);
     virtual void  addLine (uiterator b, uiterator e);
@@ -264,7 +263,7 @@ class  WikiBlockItemText: public WikiBlockComplex {
     bool  indentHack;
     WikiAttrib1  attrib;
 
-    WikiBlockItemText (WikiFormat* w): WikiBlockComplex (BlockItemText, w), attrib (w, WikiAttrib1::SEL_ID) {
+    WikiBlockItemText (WikiFormat* w): WikiBlockComplex (BlockItemText, w), attrib (w, WikiAttrib1::SEL_ID, false) {
        indentHack = false;
     };
     virtual  ~WikiBlockItemText () {};
@@ -294,8 +293,6 @@ class  WikiBlockItem: public WikiBlock {
 
 class  WikiBlockItemDL: public WikiBlock {
  public:
-//    std::vector<ustring>  html1;
-//    std::vector<ustring>  html2;
     boost::ptr_vector<WikiMotorObjVec>  objv1;
     boost::ptr_vector<WikiMotorObjVec>  objv2;
 
@@ -320,7 +317,6 @@ class  WikiBlockTable: public WikiBlock {
        int  colspan;
        bool  spanmatch;
 
-//     TableCell (WikiFormat* _wiki, bool inheader): cellattrib (_wiki, WikiAttribTable::SEL_TD, inheader) {
        TableCell (WikiFormat* _wiki, WikiAttrib1::mode_t _mode): cellattrib (_wiki, WikiAttribTable::SEL_TD, _mode) {
            fcolspan = false;
            frowspan = false;
@@ -334,12 +330,10 @@ class  WikiBlockTable: public WikiBlock {
        virtual void  outputTDe (MotorOutput* out);
     };
 
-//    typedef boost::ptr_vector<TableCell>  CellList_t;
     class  CellList_t: public boost::ptr_vector<TableCell> {
     public:
        WikiAttribTable  rowattrib;
 
-//     CellList_t (WikiFormat* _wiki): rowattrib (_wiki, WikiAttribTable::SEL_TR, true) {};
        CellList_t (WikiFormat* _wiki): rowattrib (_wiki, WikiAttribTable::SEL_TR, WikiAttrib1::M_ATTRIB) {};
        virtual  ~CellList_t () {};
     };
@@ -353,7 +347,6 @@ class  WikiBlockTable: public WikiBlock {
     TableAry_t  ary;
     ustring  captionHtml;
 
-//    WikiBlockTable (WikiFormat* _wiki): WikiBlock (BlockTable, _wiki), attrib (_wiki, WikiAttribTable::SEL_TABLE, true), defaultList (_wiki) {
     WikiBlockTable (WikiFormat* _wiki): WikiBlock (BlockTable, _wiki), attrib (_wiki, WikiAttribTable::SEL_TABLE, WikiAttrib1::M_ATTRIB_TEXT), defaultList (_wiki) {
        n = 0;
        cont = false;
@@ -390,11 +383,9 @@ class  WikiBlockSelect: public WikiBlock {
 
     int  n;
     ustring  name;
-//    WikiAttrib1  attrib;
     WikiAttribInput  attrib;
     std::vector<SelectItem>  item;
 
-//    WikiBlockSelect (WikiFormat* w): WikiBlock (BlockSelect, w), attrib (w, WikiAttrib1::SEL_ELSIZE | WikiAttrib1::SEL_DEFAULT2 | WikiAttrib1::SEL_MULTIPLE2 | WikiAttrib1::SEL_SCRIPT2, true) {
     WikiBlockSelect (WikiFormat* w): WikiBlock (BlockSelect, w), attrib (w, WikiAttribInput::SEL_ELSIZE) {
        attrib.selector |= WikiAttrib1::SEL_DEFAULT2 | WikiAttrib1::SEL_MULTIPLE2 | WikiAttrib1::SEL_SCRIPT2;
        n = 0;
@@ -425,7 +416,6 @@ class  WikiBlockDiv: public WikiBlockComplex {
  public:
     WikiAttrib1  attrib;
 
-//    WikiBlockDiv (WikiFormat* w): WikiBlockComplex (BlockDiv, w), attrib (w, WikiAttrib1::SEL_CLASS2, true) {};
     WikiBlockDiv (WikiFormat* w): WikiBlockComplex (BlockDiv, w), attrib (w, WikiAttrib1::SEL_CLASS2, WikiAttrib1::M_ATTRIB) {};
     virtual  ~WikiBlockDiv () {};
 
@@ -447,7 +437,6 @@ class  WikiBlockForm: public WikiBlockComplex {
     bool  fscript;
     bool  qfileform;
 
-//    WikiBlockForm (WikiFormat* w): WikiBlockComplex (BlockForm, w), attrib (w, WikiAttrib1::SEL_TARGET, true) {
     WikiBlockForm (WikiFormat* w): WikiBlockComplex (BlockForm, w), attrib (w, WikiAttrib1::SEL_TARGET, WikiAttrib1::M_ATTRIB) {
        method = M_NONE;
        fscript = false;
@@ -502,8 +491,6 @@ class  WikiFormat {
        };
        virtual bool  test () {
            return wiki->depth >= 32;
-//         if (wiki->depth >= 32)
-//             throw (uErrorInclNest);
        };
     };
 
@@ -600,7 +587,7 @@ class  WikiFormat {
     virtual void  outputFlag (MotorOutput* out, const char* name, size_t len, bool flag);
     virtual void  outputID (MotorOutput* out, const ustring& id);
     virtual void  outputClass (MotorOutput* out, std::vector<ustring>& classes);
-    virtual void  outputSubmitScript (MotorOutput* out, const char* name, size_t len, const ustring& onclick);
+    virtual void  outputSubmitScript (MotorOutput* out, const char* name, size_t len, const ustring& onclick, bool scriptcut);
     virtual ustring  getVar (const ustring& name) {
        return mlenv->getVar_string (name);
     };
index 8a82bce..3b1410f 100644 (file)
@@ -498,7 +498,7 @@ bool  wl_file (WikiMotorObjVecVec* args, WikiMotorObjVec& out, WikiFormat* wiki)
 bool  wl_button_sub (const char* name, size_t len, WikiMotorObjVecVec* args, WikiMotorObjVec* arg2, WikiMotorObjVec& out, WikiFormat* wiki) {
     WikiMotorObjVecVec::const_iterator  b = args->begin ();
     WikiMotorObjVecVec::const_iterator  e = args->end ();
-    WikiAttribButton  attrib (wiki);
+    WikiAttribButton  attrib (wiki, true);
     MotorOutputString  html;
 
     if (! attrib.readAttrib (b, e))