MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fx_parseURLHostSpecial

Function fx_parseURLHostSpecial

modules/data/url/url.c:1226–1294  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1224}
1225
1226txBoolean fx_parseURLHostSpecial(txMachine* the, txStringStream* src, txInteger from, txInteger to, txStringStream* dst)
1227{
1228 txBoolean result = 1;
1229 txInteger offset = src->offset;
1230 txInteger flag = 0;
1231 src->offset = from;
1232 while (src->offset < to) {
1233 txInteger c = fx_parseURLDecode(the, src);
1234 if (c < 0x80) {
1235 if (('A' <= c) && (c <= 'Z'))
1236 c -= ('A' - 'a');
1237 else if (c == '%')
1238 flag |= 1;
1239 else if (c_read8(gxSpecialHostSet + c)) {
1240 result = 0;
1241 break;
1242 }
1243 }
1244 else {
1245
1246 flag |= 2;
1247 }
1248 fx_parseURLEncode(the, c, dst);
1249 }
1250 if (result && (flag & 1)) {
1251 txStringStream _tmp;
1252 txStringStream* tmp = &_tmp;
1253 mxTry(the) {
1254 mxPush(mxGlobal);
1255 mxDub();
1256 mxGetID(mxID(_decodeURIComponent));
1257 mxCall();
1258 mxPushSlot(dst->slot);
1259 mxRunCount(1);
1260 tmp->slot = the->stack;
1261 tmp->offset = 0;
1262 tmp->size = 0;
1263 dst->offset = 0;
1264 dst->slot->value.string[0] = 0;
1265 for (;;) {
1266 txInteger c = fx_parseURLDecode(the, tmp);
1267 if (c == C_EOF)
1268 break;
1269 if (c < 0x80) {
1270 if (c_read8(gxSpecialHostSet + c)) {
1271 result = 0;
1272 break;
1273 }
1274 if (('A' <= c) && (c <= 'Z'))
1275 c -= ('A' - 'a');
1276 }
1277 else
1278 flag |= 2;
1279 fx_parseURLEncode(the, c, dst);
1280 }
1281 mxPop();
1282 }
1283 mxCatch(the) {

Callers 1

fx_parseURLHostFunction · 0.85

Calls 2

fx_parseURLDecodeFunction · 0.85
fx_parseURLEncodeFunction · 0.85

Tested by

no test coverage detected