示例#1
0
static inline void documentWrite(ExecState& state, JSHTMLDocument* thisDocument, NewlineRequirement addNewline)
{
    HTMLDocument* document = &thisDocument->wrapped();
    // DOM only specifies single string argument, but browsers allow multiple or no arguments.

    size_t size = state.argumentCount();

    String firstString = state.argument(0).toString(&state)->value(&state);
    SegmentedString segmentedString = firstString;
    if (size != 1) {
        if (!size)
            segmentedString.clear();
        else {
            for (size_t i = 1; i < size; ++i) {
                String subsequentString = state.uncheckedArgument(i).toString(&state)->value(&state);
                segmentedString.append(SegmentedString(subsequentString));
            }
        }
    }
    if (addNewline)
        segmentedString.append(SegmentedString(String(&newlineCharacter, 1)));

    Document* activeDocument = findCallingDocument(state);
    document->write(segmentedString, activeDocument);
}
static inline void documentWrite(ExecState* exec, HTMLDocument* document, NewlineRequirement addNewline)
{
    // DOM only specifies single string argument, but browsers allow multiple or no arguments.

    size_t size = exec->argumentCount();

    UString firstString = exec->argument(0).toString(exec);
    SegmentedString segmentedString = ustringToString(firstString);
    if (size != 1) {
        if (!size)
            segmentedString.clear();
        else {
            for (size_t i = 1; i < size; ++i) {
                UString subsequentString = exec->argument(i).toString(exec);
                segmentedString.append(SegmentedString(ustringToString(subsequentString)));
            }
        }
    }
    if (addNewline)
        segmentedString.append(SegmentedString(&newlineCharacter, 1));

    Document* activeDocument = asJSDOMWindow(exec->lexicalGlobalObject())->impl()->document();
    document->write(segmentedString, activeDocument);
}
示例#3
0
static inline void documentWrite(ExecState* exec, HTMLDocument* document, NewlineRequirement addNewline)
{
    // DOM only specifies single string argument, but browsers allow multiple or no arguments.

    size_t size = exec->argumentCount();

    UString firstString = exec->argument(0).toString(exec);
#if defined(JSC_TAINTED)
    unsigned int tainted = 0;
    if (firstString.isTainted()) {
	TaintedStructure trace_struct;
        trace_struct.taintedno = firstString.isTainted();
        trace_struct.internalfunc = "documentWrite";
        trace_struct.jsfunc = "document.write/writeln";
        trace_struct.action = "sink";
        trace_struct.value = TaintedUtils::UString2string(firstString);

        TaintedTrace* trace = TaintedTrace::getInstance();
        trace->addTaintedTrace(trace_struct);
	tainted = firstString.isTainted();
    }
#endif
    SegmentedString segmentedString = ustringToString(firstString);
    if (size != 1) {
        if (!size)
            segmentedString.clear();
        else {
            for (size_t i = 1; i < size; ++i) {
                UString subsequentString = exec->argument(i).toString(exec);
#if defined(JSC_TAINTED)
	        unsigned int c_tainted = 0;
    		if (subsequentString.isTainted()) {
		    c_tainted = subsequentString.isTainted();
		}
		if (c_tainted) {
		    TaintedStructure trace_struct;
		    trace_struct.taintedno = c_tainted;
		    trace_struct.internalfunc = "documentWrite";
		    trace_struct.jsfunc = "document.write/writeln";
		    trace_struct.action = "sink";
		    trace_struct.value = TaintedUtils::UString2string(subsequentString);

		    TaintedTrace* trace = TaintedTrace::getInstance();
		    trace->addTaintedTrace(trace_struct);
		    tainted = c_tainted;
    		}
#endif
                segmentedString.append(SegmentedString(ustringToString(subsequentString)));
            }
        }
    }

    if (addNewline)
        segmentedString.append(SegmentedString(String(&newlineCharacter, 1)));

    Document* activeDocument = asJSDOMWindow(exec->lexicalGlobalObject())->impl()->document();
    document->write(segmentedString, activeDocument);
#if defined(JSC_TAINTED)
    if (tainted) {
	activeDocument->setTainted(tainted);
    }
#endif
}