Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSoC IPPServer Functionality #120 #121 #122 #139

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 60 additions & 2 deletions cups/ipp-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ _ippFileParse(
{
_ippVarsExpand(v, value, temp, sizeof(value));
_ippVarsSet(v, name, value);
}
}
}
else
{
Expand Down Expand Up @@ -644,11 +644,69 @@ parse_value(_ipp_file_t *f, /* I - IPP data file */
break;

case IPP_TAG_STRING :
return (ippSetOctetString(ipp, attr, element, value, (int)strlen(value)));
{
if(value[0]=='<') /* Input is binary(in form of hex) values*/
{
unsigned char data[32767], *dataptr = data; /*data: decoded hex, dataptr:iterating pointer */
char *valptr = value + 1; /*Value iterating pointer*/
while (1)
{
while (isxdigit(valptr[0]) && isxdigit(valptr[1]))
{
char c = valptr[0], d=valptr[1];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need "tolower" here, as "isxdigit" allows upper and lowercase letters.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

/*decode hex pair into 8 bit string */
dataptr = (d>='a')?(10+d-'a'):(d-'0') + (c>= 'a') ? ((10+c -'a') << 4) : ((c-'0') <<4);
valptr += 2;
dataptr ++;
if (dataptr >= (data + sizeof(data)))
break;
}
if (*valptr == '>')
break;
else if (*valptr) /*If string is not in pairs, or has a non-hex digit*/
{
report_error(f, v, user_data, "Bad hexadecimal value \"%s\" on line %d of \"%s\".", value+1, f->linenum, f->filename);
return (0);
}
if (!_ippFileReadToken(f, value, sizeof(value)))
{
report_error(f, v, user_data, "Missing value on line %d of \"%s\".", f->linenum, f->filename);
return (0);
}
valptr = value;
}
return (ippSetOctetString(ipp, attr, element, data, (int)strlen(data)));
}

else
{
return (ippSetOctetString(ipp, attr, element, value, (int)strlen(value))); /* If a quoted string like "..", pass it on */
}

}

break;

case IPP_TAG_TEXTLANG :
case IPP_TAG_NAMELANG :
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the same code for IPP_TAG_NAMELANG and IPP_TAG_TEXTLANG (with the two case statements together feeding into the same code).

(*attr)->values[element].string.text = _cupsStrAlloc(value);
if (!_ippFileReadToken(f, value, sizeof(value)))
{
report_error(f, v, user_data, "No Language Data in line %d of \"%s\".", f->linenum, f->filename);
return (0);
}
if (!(value[0] == '(' && value[strlen(value)-1] == ')'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you need to read another token here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi!
For input like "my string"(language), the var, value, at line 695, initially contains 'my string' , which then is fed into string.text.
Next a token i.e. (language) is read into var value at line 696, which then is fed into string.language.
I don't think another token needs to be read here, is it ?

{
report_error(f, v, user_data, "Bad Language Value in line %d of \"%s\".", f->linenum, f->filename);
return (0);
}
memmove(value, value+1, strlen(value));
value[strlen(value)-1]='\0'; /* Purge parenthesis */
(*attr)->values[element].string.language = _cupsStrAlloc(value);

}
break;
case IPP_TAG_TEXT :
case IPP_TAG_NAME :
case IPP_TAG_KEYWORD :
Expand Down