MCPcopy Create free account
hub / github.com/OpenBoard-org/OpenBoard / parse

Method parse

src/web/UBEmbedParser.cpp:75–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73
74
75void UBEmbedParser::parse(const QString& html)
76{
77 if (mParsing)
78 {
79 // abort any pending network requests for oEmbed information
80 qDebug() << "abort oembed parsing";
81 mParsing = false;
82 emit cancelled();
83 }
84
85 qDebug() << "parse" << html.length() << "bytes";
86 mParsing = true;
87 mContents.clear();
88 mParsedTitles.clear();
89
90 // extract all <link> and <iframe> tags upto but not including the final >
91 static const QRegularExpression exp("(<|&lt;)(link|iframe)([^>]*)");
92 QStringList results;
93 int count = 0;
94 QRegularExpressionMatchIterator matches = exp.globalMatch(html);
95
96 while (matches.hasNext())
97 {
98 QRegularExpressionMatch match = matches.next();
99 ++count;
100 QStringList res = match.capturedTexts();
101
102 if ("" != res.at(0))
103 {
104 results << res.at(0);
105 }
106 }
107
108 QList<QString> oembedUrls;
109
110 for (QString result : std::as_const(results))
111 {
112 // replace entities
113 result = result.trimmed().replace("&lt;", "<").replace("&gt;", ">").replace("\\&quot;", "\"").replace("\\", "");
114
115 // again cut at first ">"
116 int greater = result.indexOf('>');
117
118 if (greater >= 0)
119 {
120 result.truncate(greater);
121 }
122
123 // add trailing slash if necessary
124 if (result.at(result.length() - 1) != '/')
125 {
126 result += "/";
127 }
128
129 QString qsNode = result + ">";
130
131 if (qsNode.startsWith("<iframe"))
132 {

Callers 15

sFunction · 0.45
loadOptionsFunction · 0.45
$Function · 0.45
soapclient.jsFile · 0.45
XMLDocFunction · 0.45
_XMLDoc_loadXMLFunction · 0.45
OpenLayers.jsFile · 0.45

Calls 9

trimmedMethod · 0.80
truncateMethod · 0.80
emptyMethod · 0.80
lengthMethod · 0.45
clearMethod · 0.45
typeMethod · 0.45
containsMethod · 0.45
valueMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected